Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Eap7.4.x #20

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Restyle Eap7.4.x #20

merged 1 commit into from
Oct 31, 2024

Conversation

restyled-io[bot]
Copy link

@restyled-io restyled-io bot commented Oct 31, 2024

Automated style fixes for #17, created by Restyled.

The following restylers made fixes:

To incorporate these changes, merge this Pull Request into the original. We
recommend using the Squash or Rebase strategies.

NOTE: As work continues on the original Pull Request, this process will
re-run and update (force-push) this Pull Request with updated style fixes as
necessary. If the style is fixed manually at any point (i.e. this process finds
no fixes to make), this Pull Request will be closed automatically.

Sorry if this was unexpected. To disable it, see our documentation.

Summary by Sourcery

Enhancements:

  • Apply automated style fixes using clang-format across multiple Java files to improve code consistency and readability.

Copy link

cr-gpt bot commented Oct 31, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copy link

sourcery-ai bot commented Oct 31, 2024

Reviewer's Guide by Sourcery

This PR contains automated style fixes applied by the clang-format tool, focusing on line wrapping and string concatenation formatting in Java files. The changes are purely cosmetic and do not affect functionality.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Reformatted string concatenation using the '+' operator
  • Moved '+' operator to the end of lines instead of beginning of next line
  • Added spaces around '+' operator for better readability
  • Fixed indentation of wrapped string concatenations
impl/src/main/java/org/jboss/weld/logging/BeanLogger.java
impl/src/main/java/org/jboss/weld/logging/BootstrapLogger.java
environments/se/core/src/main/java/org/jboss/weld/environment/se/logging/WeldSELogger.java
environments/common/src/main/java/org/jboss/weld/environment/logging/CommonLogger.java
modules/web/src/main/java/org/jboss/weld/module/web/logging/ServletLogger.java
Reformatted long string literals and message declarations
  • Split long strings across multiple lines with proper indentation
  • Aligned wrapped string literals consistently
  • Fixed formatting of message annotations and their parameters
environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/injection/FilterInjectionTest.java
environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/injection/ListenerInjectionTest.java
tests-arquillian/src/test/java/org/jboss/weld/tests/resources/EMFFactoryTest.java
impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

korbit-ai bot commented Oct 31, 2024

By default, I don't review pull requests opened by bots. If you would like me to review this pull request anyway, you can request a review via the /korbit-review command in a comment.

Copy link

Processing PR updates...

Copy link

git-greetings bot commented Oct 31, 2024

Thanks @restyled-io[bot] for opening this PR!

For COLLABORATOR only :

  • To add labels, comment on the issue
    /label add label1,label2,label3

  • To remove labels, comment on the issue
    /label remove label1,label2,label3

Copy link

Unable to locate .performanceTestingBot config file

Copy link

@gitginie gitginie bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@restyled-io[bot]
Thank you for your contribution to this repository! We appreciate your effort in opening pull request.
Happy coding!

@labels-and-badges labels-and-badges bot added NO JIRA This PR does not have a Jira Ticket PR:size/XL Denotes a Pull Request that changes 500-999 lines. labels Oct 31, 2024
Copy link

git-greetings bot commented Oct 31, 2024

PR Details of @restyled-io[bot] in weld-core :

OPEN CLOSED TOTAL
10 10 20

Copy link

Description has been updated!

Copy link

coderabbitai bot commented Oct 31, 2024

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have skipped reviewing this pull request. It seems to have been created by a bot (hey, restyled-io[bot]!). We assume it knows what it's doing!

@2lambda123 2lambda123 merged commit 5d1fd80 into eap7.4.x Oct 31, 2024
13 of 24 checks passed
Copy link

@gitginie gitginie bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@restyled-io[bot]
Thank you for your contribution to this repository! We appreciate your effort in closing pull request.
Happy coding!

Comment on lines 49 to 55
@LogMessage(level = Level.WARN)
@Message(id = 4,
value = "Could not invoke JNLPClassLoader#getJarFile(URL) on " +
"context class loader, expecting Web Start class loader",
value = "Could not invoke JNLPClassLoader#getJarFile(URL) on "
+ "context class loader, expecting Web Start class loader",
format = Format.MESSAGE_FORMAT)
void
unexpectedClassLoader(@Cause Throwable cause);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method unexpectedClassLoader logs a warning when an unexpected class loader is encountered, but it lacks parameters that could provide more context about the issue, such as the URL or specific class loader that was expected. This makes debugging more difficult.

Recommendation:
Consider adding parameters to capture the URL and the expected class loader type. This would provide more actionable information in the log message, aiding in quicker resolution of issues.

Comment on lines 63 to 69
@LogMessage(level = Level.WARN)
@Message(id = 6,
value = "Could not invoke JNLPClassLoader#getJarFile(URL) on " +
"context class loader",
value = "Could not invoke JNLPClassLoader#getJarFile(URL) on "
+ "context class loader",
format = Format.MESSAGE_FORMAT)
void
jnlpClassLoaderInvocationException(@Cause Throwable cause);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method jnlpClassLoaderInvocationException logs when JNLPClassLoader#getJarFile(URL) cannot be invoked, but it only includes a Throwable for the cause and lacks details about the URL or the context that led to the exception.

Recommendation:
Enhance the method by including a parameter for the URL that was being accessed when the exception occurred. This additional detail would improve the utility of the log message for debugging purposes.

value = "Bean class {0} found in multiple bean archives - this " +
"may result in incorrect behavior: {1}",
value = "Bean class {0} found in multiple bean archives - this "
+ "may result in incorrect behavior: {1}",
format = Format.MESSAGE_FORMAT)
void
beanClassDeployedInMultipleBeanArchives(Object beanClass, Object bdas);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods multipleContainersRunning and beanClassDeployedInMultipleBeanArchives use Object as the parameter type for their inputs. This generic type does not enforce any specific type of input, which could lead to runtime errors if an incompatible type is passed. It is recommended to use more specific types for these parameters to ensure type safety and prevent potential runtime issues. For example, if ids is expected to be a collection of identifiers, using Collection<?> or a more specific collection type would be more appropriate.

Comment on lines 99 to 106
observedTypeNotContonainerLifecycleEventType(Object type);

@Message(id = 2011,
value = "The observed type {0} does not match the container " +
"lifecycle event type {1}",
value = "The observed type {0} does not match the container "
+ "lifecycle event type {1}",
format = Format.MESSAGE_FORMAT)
IllegalArgumentException
observedTypeDoesNotMatchContonainerLifecycleEventType(Object type,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method observedTypeDoesNotMatchContonainerLifecycleEventType uses Object for the parameters type and eventType, which is overly generic and could lead to type mismatches at runtime. To improve type safety and maintainability, consider specifying more concrete types for these parameters, such as Class<?> or a specific interface that all event types should implement. This change would help prevent type errors and make the code more robust.

Comment on lines +145 to +146
fail("Invoking Handle.get() after destroying contextual instance "
+ "should throw an exception.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure message in fail() is generic and could be improved for better clarity. When the test fails because the IllegalStateException is not thrown, the message should clearly state what was expected and what the actual behavior was. This will aid in debugging and understanding the test failure.

Recommended Change:

fail("Expected IllegalStateException to be thrown when accessing a destroyed contextual instance via Handle.get(), but no exception was thrown.");

Comment on lines 353 to 360

// Test again using the proprietary "nocid" parameter (kept for backwards
// compatibility)
HtmlPage page4 = client.getPage(getPath("/cloud.jsf", cid) + ("&nocid=" +
"true"));
HtmlPage page4 = client.getPage(getPath("/cloud.jsf", cid) + ("&nocid="
+ "true"));
assertEquals(Cloud.NAME,
getFirstMatchingElement(page4, HtmlSpan.class, "cloudName")
.getTextContent());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code directly appends query parameters (nocid) to the URL string, which can lead to errors and makes the code less maintainable. Consider creating a utility method for appending parameters to URLs. This method would handle the creation of parameter strings in a consistent manner, improving code maintainability and reducing the risk of bugs related to URL construction.

For example:

protected String appendParameter(String url, String param, String value) {
    return url + (url.contains("?") ? "&" : "?") + param + "=" + value;
}

This method can then be used to append parameters safely to any URL.

Comment on lines 129 to 131
} catch (IllegalStateException e) {
// expected
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the catch block correctly expects an IllegalStateException, it does not verify the exception's message. This can lead to false positives if the exception is thrown for a different reason than expected. Recommendation: Enhance the exception handling by checking the exception message to ensure it matches the expected outcome. For example:

} catch (IllegalStateException e) {
    assertEquals("Expected exception message", e.getMessage());
}

@@ -124,8 +124,8 @@ public void testGetAfterDestroyingContextualInstance(Client client) {
// try to invoke Handle.get() again; this should throw an exception
try {
alphaHandle.get();
fail("Invoking Handle.get() after destroying contextual instance " +
"should throw an exception.");
fail("Invoking Handle.get() after destroying contextual instance "

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure message in fail() is generic and does not provide specific details about why the test failed, which could lead to confusion during debugging. Recommendation: Update the failure message to be more descriptive about the expected behavior and why the test failed. For example:

fail("Expected IllegalStateException was not thrown after destroying contextual instance.");

Comment on lines 42 to 49
public static final Asset PERSISTENCE_XML = new ByteArrayAsset(
("<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\" " +
"version=\"1.0\"><persistence-unit " +
"name=\"pu1\"><jta-data-source>java:jboss/datasources/ExampleDS</" +
"jta-data-source></persistence-unit></persistence>").getBytes());
("<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\" "
+ "version=\"1.0\"><persistence-unit "
+ "name=\"pu1\"><jta-data-source>java:jboss/datasources/ExampleDS</"
+ "jta-data-source></persistence-unit></persistence>")
.getBytes());
public static final Asset EMPTY_BEANS_XML =
new ByteArrayAsset("<beans />".getBytes());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML configurations for PERSISTENCE_XML and EMPTY_BEANS_XML are hardcoded directly in the Java class. This approach can lead to maintenance challenges, especially if the XML needs to be modified or is subject to frequent changes. Consider externalizing these XML configurations into separate resource files or using a builder pattern to construct these XML strings dynamically. This would improve the maintainability and readability of the code.

Recommended Solution:

  • Move the XML strings to separate XML configuration files and load them as resources.
  • Alternatively, use a builder or factory pattern to construct these XML strings dynamically within the code.

Comment on lines +47 to 49
.getBytes());
public static final Asset EMPTY_BEANS_XML =
new ByteArrayAsset("<beans />".getBytes());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getBytes() is used without specifying a character encoding, which can lead to inconsistent behavior across different platforms where the default charset is different. To ensure consistent behavior, always specify the charset when converting a string to bytes.

Recommended Solution:

  • Modify the getBytes() calls to specify a charset, for example, getBytes(StandardCharsets.UTF_8). This ensures that the byte representation of the strings is consistent regardless of the platform's default charset.

Comment on lines 78 to 93

@LogMessage(level = Level.WARN)
@Message(id = 10,
value = "Could not open the stream on the url {0} when adding to " +
"the jandex index.",
value = "Could not open the stream on the url {0} when adding to "
+ "the jandex index.",
format = Format.MESSAGE_FORMAT)
void
couldNotOpenStreamForURL(Object param1, @Cause Throwable cause);

@LogMessage(level = Level.WARN)
@Message(id = 11,
value = "Could not close the stream on the url {0} when adding to " +
"the jandex index.",
value = "Could not close the stream on the url {0} when adding to "
+ "the jandex index.",
format = Format.MESSAGE_FORMAT)
void
couldNotCloseStreamForURL(Object param1, @Cause Throwable cause);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods couldNotOpenStreamForURL and couldNotCloseStreamForURL log warnings about issues with stream operations on URLs. While these methods effectively log the occurrence of errors, they could be improved by providing more specific details about the nature of the errors or potential recovery steps. This would enhance the utility of the logs for debugging and operational maintenance.

Recommendation: Enhance the error messages to include suggestions for troubleshooting or more detailed descriptions of the error conditions.

Comment on lines 231 to 238
unableToInitializeProbeComponent(Object component, @Cause Throwable cause);

@Message(id = 38,
value = "Development mode is enabled but the following Probe " +
"component is not found on the classpath: {0}",
value = "Development mode is enabled but the following Probe "
+ "component is not found on the classpath: {0}",
format = Format.MESSAGE_FORMAT)
IllegalStateException
probeComponentNotFoundOnClasspath(Object component);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods unableToInitializeProbeComponent and probeComponentNotFoundOnClasspath handle errors related to the Probe component. These methods currently log the issues but do not provide guidance on how to resolve them or the potential impact of these errors on the system.

Recommendation: Include recovery suggestions or additional context about the implications of these errors in the log messages. This could help in quicker resolution and understanding the severity of the issues.

value = "Bean class {0} found in multiple bean archives - this " +
"may result in incorrect behavior: {1}",
value = "Bean class {0} found in multiple bean archives - this "
+ "may result in incorrect behavior: {1}",
format = Format.MESSAGE_FORMAT)
void
beanClassDeployedInMultipleBeanArchives(Object beanClass, Object bdas);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Generic Object Type for Parameters

The methods multipleContainersRunning and beanClassDeployedInMultipleBeanArchives use Object as the type for their parameters. This is overly generic and can lead to runtime type errors if the passed objects are not compatible with the expected format operations.

Recommendation:
Refine the parameter types to more specific classes or interfaces that accurately reflect the expected input. This change would enhance type safety, reduce the risk of runtime errors, and improve the readability and maintainability of the code.

Comment on lines 165 to 167
format = Format.MESSAGE_FORMAT)
IllegalArgumentException
failedToLoadClass(String className, String exception);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Inclusion of Raw Exception Messages

The method failedToLoadClass includes the raw message of an exception ({1}) in the output. This practice can potentially expose sensitive information or details about the internal implementation.

Recommendation:
Avoid directly including exception messages in user-facing outputs. Instead, log these details at an appropriate level internally and provide a generic error message to the user. This approach helps in safeguarding sensitive information and maintaining a clean separation between internal diagnostics and user-facing messages.

Comment on lines +145 to +146
fail("Invoking Handle.get() after destroying contextual instance "
+ "should throw an exception.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure message in fail() method is generic and does not provide specific details about the context or reason for the failure. Consider providing a more detailed message that includes the expected behavior and why the test should fail if alphaHandle.get() does not throw an exception. This will improve the maintainability and understandability of the test.

Suggested Improvement:

fail("Expected IllegalStateException when invoking get() on a destroyed contextual instance of Alpha.");

Comment on lines +356 to +357
HtmlPage page4 = client.getPage(getPath("/cloud.jsf", cid) + ("&nocid="
+ "true"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of a proprietary query parameter 'nocid' for controlling conversation propagation is not a standard practice and can lead to maintenance issues. Consider using standard mechanisms for session and conversation management provided by the framework or protocol you are working with. This approach will make the code more maintainable and understandable to developers who are not familiar with the proprietary extensions.

Comment on lines +356 to +357
HtmlPage page4 = client.getPage(getPath("/cloud.jsf", cid) + ("&nocid="
+ "true"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructing URLs by directly concatenating strings with query parameters, as seen here with the 'nocid' parameter, can lead to errors and is not scalable if the URL structure becomes more complex. It's recommended to use a utility method for building URLs with query parameters. This method would handle URL encoding issues and make the code cleaner and easier to maintain.

Comment on lines 124 to 131
// try to invoke Handle.get() again; this should throw an exception
try {
alphaHandle.get();
fail("Invoking Handle.get() after destroying contextual instance " +
"should throw an exception.");
fail("Invoking Handle.get() after destroying contextual instance "
+ "should throw an exception.");
} catch (IllegalStateException e) {
// expected
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception handling in the test method testGetAfterDestroyingContextualInstance could be improved for better maintainability and clarity. Currently, the catch block is empty, and the test relies on fail() to indicate a test failure when no exception is thrown. This approach might not provide sufficient diagnostic information if the test fails. Consider asserting the exception message or type directly using JUnit's exception handling features, such as assertThrows, to make the test more robust and informative.

Recommended Change:

assertThrows(IllegalStateException.class, () -> alphaHandle.get());

This change ensures that the test will only pass if the expected exception is thrown, and it also makes the test output more descriptive in case of failure.

Comment on lines 42 to 49
public static final Asset PERSISTENCE_XML = new ByteArrayAsset(
("<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\" " +
"version=\"1.0\"><persistence-unit " +
"name=\"pu1\"><jta-data-source>java:jboss/datasources/ExampleDS</" +
"jta-data-source></persistence-unit></persistence>").getBytes());
("<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\" "
+ "version=\"1.0\"><persistence-unit "
+ "name=\"pu1\"><jta-data-source>java:jboss/datasources/ExampleDS</"
+ "jta-data-source></persistence-unit></persistence>")
.getBytes());
public static final Asset EMPTY_BEANS_XML =
new ByteArrayAsset("<beans />".getBytes());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML configurations for PERSISTENCE_XML and EMPTY_BEANS_XML are hardcoded directly in the source code. This approach is not maintainable and makes the codebase less flexible to changes. Consider externalizing these XML configurations into separate resource files or using a configuration management tool. This would not only make the code cleaner but also easier to manage and modify in the future.

Comment on lines +47 to 49
.getBytes());
public static final Asset EMPTY_BEANS_XML =
new ByteArrayAsset("<beans />".getBytes());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getBytes() is used without specifying a charset, which relies on the JVM's default charset and can lead to inconsistencies across different environments. It is recommended to specify a charset explicitly, for example, getBytes(StandardCharsets.UTF_8), to ensure consistent behavior across various platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO JIRA This PR does not have a Jira Ticket PR:size/XL Denotes a Pull Request that changes 500-999 lines. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants