Skip to content

Conversation

russelmrcl
Copy link
Collaborator

@russelmrcl russelmrcl commented Aug 1, 2025

Summary by CodeRabbit

  • Refactor

    • Updated HTTP request creation to use a builder pattern across the application and tests.
    • Improved import statements for better clarity and specificity.
    • Modified method signatures in tests to declare additional exceptions required by the new request construction.
    • Simplified internal logic for HTTP method body handling.
  • Tests

    • Updated test setups and helper methods to support the new request construction approach.

@russelmrcl russelmrcl requested a review from predic8 August 1, 2025 10:41
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Warning

Rate limit exceeded

@predic8 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 88f7c4b and 6dd3258.

📒 Files selected for processing (1)
  • core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java (3 hunks)

Walkthrough

This change removes the utility methods for creating HTTP requests from MessageUtil and updates all core and test code to use the Request.Builder pattern directly for constructing HTTP GET, POST, and DELETE requests. Method signatures are updated to reflect new exceptions where needed, and import statements are refined for clarity and specificity. Additionally, some request creation logic was simplified and logging improved.

Changes

Cohort / File(s) Change Summary
Core HTTP Request Construction Refactor
core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java,
core/src/main/java/com/predic8/membrane/balancer/client/LBNotificationClient.java,
core/src/main/java/com/predic8/membrane/core/interceptor/WSDLInterceptor.java,
core/src/main/java/com/predic8/membrane/core/http/Request.java
Removed MessageUtil static methods for GET/POST/DELETE requests; replaced their usage with Request.Builder pattern in core code. Updated method signatures to throw URISyntaxException where necessary. Simplified request creation logic and refined import statements. Minor logic simplification in Request.shouldNotContainBody(). Improved logging style in LBNotificationClient. Added helper method to extract host in WSDLInterceptor.
Test Updates for Request Construction
core/src/test/java/com/predic8/membrane/core/interceptor/DispatchingInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/WADLInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/WSDLInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/formvalidation/FormValidationInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptorTest.java,
core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectionInterceptorTest.java,
core/src/test/java/com/predic8/membrane/interceptor/ws_addressing/WsaEndpointRewriterInterceptorTest.java
Updated all test cases to construct HTTP requests using Request.Builder instead of removed MessageUtil methods. Adjusted method signatures to throw URISyntaxException where needed. Refined imports for specificity and consistency. Minor changes to test method visibility and assertion argument order for clarity. Changed some expected URI strings in tests to relative paths.

Sequence Diagram(s)

sequenceDiagram
    participant TestCase
    participant RequestBuilder
    participant Exchange

    TestCase->>RequestBuilder: Request.get(uri).build()
    RequestBuilder-->>TestCase: Request object
    TestCase->>Exchange: setRequest(Request)
Loading
sequenceDiagram
    participant CoreClass
    participant RequestBuilder

    CoreClass->>RequestBuilder: Request.post(uri).build()
    RequestBuilder-->>CoreClass: Request object
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In the warren, code gets neat,
No more wildcards, no more cheat.
Builders now make every request,
With clearer imports—code at its best!
The bunnies hop, the tests all run,
Refactoring’s work is never done.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-message-util

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@membrane-ci-server
Copy link

This pull request needs "/ok-to-test" from an authorized committer.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java (1)

82-88: Nitpick: Fix typo in method name

The method name getStandartRequest should be getStandardRequest (missing 'd' in "Standard").

-private static Request getStandartRequest(String method) {
+private static Request getStandardRequest(String method) {
core/src/test/java/com/predic8/membrane/core/interceptor/DispatchingInterceptorTest.java (1)

16-27: Consider updating to explicit imports for consistency

Other files in this PR were updated to use explicit imports instead of wildcard imports. Consider updating this file for consistency.

core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java (2)

43-43: LGTM! Correct implementation of Request.Builder pattern

The replacement correctly implements the new builder pattern, though using the full package name is unusual.

Consider adding an explicit import for Request and using the shorter form for consistency with other files:

+import com.predic8.membrane.core.http.Request;
...
-exc.setRequest(new com.predic8.membrane.core.http.Request.Builder().get("http://localhost/axis2/services/BLZService?wsdl").build());
+exc.setRequest(new Request.Builder().get("http://localhost/axis2/services/BLZService?wsdl").build());

16-28: Consider updating to explicit imports for consistency

Other files in this PR were updated to use explicit imports instead of wildcard imports. Consider updating this file for consistency with the refactoring pattern.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3bcfa3 and 9ada2ec.

📒 Files selected for processing (12)
  • core/src/main/java/com/predic8/membrane/balancer/client/LBNotificationClient.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/WSDLInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/DispatchingInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/WADLInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/WSDLInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/formvalidation/FormValidationInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptorTest.java (3 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptorTest.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectionInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/interceptor/ws_addressing/WsaEndpointRewriterInterceptorTest.java (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: rrayst
PR: membrane/api-gateway#1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Request class throws jakarta.mail.internet.ParseException, not java.text.ParseException, making the jakarta.mail.internet.ParseException import necessary and correct in JsonSchemaTestSuiteTests.java.
Learnt from: rrayst
PR: membrane/api-gateway#1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Message class (which Request extends) throws jakarta.mail.internet.ParseException because it creates a ContentType object for parsing MIME media types. The jakarta.mail.internet.ParseException import is correct and necessary in test files that call mediaType().
📚 Learning: the mediatype method in the request class throws jakarta.mail.internet.parseexception, not java.text...
Learnt from: rrayst
PR: membrane/api-gateway#1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Request class throws jakarta.mail.internet.ParseException, not java.text.ParseException, making the jakarta.mail.internet.ParseException import necessary and correct in JsonSchemaTestSuiteTests.java.

Applied to files:

  • core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/DispatchingInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectionInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/WSDLInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/formvalidation/FormValidationInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptorTest.java
  • core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/WSDLInterceptor.java
  • core/src/test/java/com/predic8/membrane/interceptor/ws_addressing/WsaEndpointRewriterInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/WADLInterceptorTest.java
📚 Learning: the mediatype method in the message class (which request extends) throws jakarta.mail.internet.parse...
Learnt from: rrayst
PR: membrane/api-gateway#1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Message class (which Request extends) throws jakarta.mail.internet.ParseException because it creates a ContentType object for parsing MIME media types. The jakarta.mail.internet.ParseException import is correct and necessary in test files that call mediaType().

Applied to files:

  • core/src/test/java/com/predic8/membrane/core/interceptor/rest/HTTP2XMLInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/WSDLInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/formvalidation/FormValidationInterceptorTest.java
  • core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/WADLInterceptorTest.java
🔇 Additional comments (26)
core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java (1)

16-32: LGTM! Import statements properly refined

The changes correctly replace wildcard imports with explicit imports and reduce static imports to only what's needed. This improves code clarity and reduces namespace pollution.

core/src/test/java/com/predic8/membrane/interceptor/ws_addressing/WsaEndpointRewriterInterceptorTest.java (2)

16-26: LGTM! Import statements properly refined

The explicit imports improve code clarity and maintainability compared to wildcard imports.


44-44: LGTM! Correct implementation of Request.Builder pattern

The replacement of MessageUtil.getPostRequest() with new Request.Builder().post(...).build() is correctly implemented and maintains the same functionality.

core/src/test/java/com/predic8/membrane/core/interceptor/DispatchingInterceptorTest.java (3)

47-47: LGTM! Correct implementation of Request.Builder pattern

The replacement of MessageUtil.getGetRequest() with new Request.Builder().get(...).build() is correctly implemented.


60-60: LGTM! Correct implementation of Request.Builder pattern

The replacement maintains the same functionality with the new builder pattern.


65-65: Clarify the purpose of this comment

The comment "//dont work!!!!" suggests there's a known issue with this test. Please clarify what doesn't work or remove the comment if it's no longer relevant.

core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectionInterceptorTest.java (2)

17-28: LGTM! Import statements properly refined

The explicit imports improve code maintainability and reduce namespace pollution.


37-37: LGTM! Correct implementation of Request.Builder pattern

The replacement of MessageUtil.getGetRequest() with new Request.Builder().get(...).build() maintains the same functionality with the new builder pattern.

core/src/test/java/com/predic8/membrane/core/interceptor/WSDLInterceptorTest.java (2)

17-17: LGTM: Proper import added for Request class.

The import addition aligns with the refactoring to use Request.Builder directly.


41-43: Add URISyntaxException to setUp method signature.

The Request.Builder().get() method can throw URISyntaxException, but the setUp method doesn't declare this exception.

 @BeforeEach
-public void setUp() throws Exception {
+public void setUp() throws Exception {

Actually, since setUp already throws Exception, URISyntaxException is already covered. The refactoring from MessageUtil.getGetRequest() to Request.Builder pattern is correctly implemented.

⛔ Skipped due to learnings
Learnt from: rrayst
PR: membrane/api-gateway#1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Request class throws jakarta.mail.internet.ParseException, not java.text.ParseException, making the jakarta.mail.internet.ParseException import necessary and correct in JsonSchemaTestSuiteTests.java.
core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptorTest.java (2)

17-35: LGTM: Import statements cleaned up properly.

The refactoring from wildcard imports to explicit imports improves code clarity and follows best practices.


58-63: LGTM: Proper exception handling and Request.Builder usage.

The method signature correctly declares URISyntaxException, and the replacement of MessageUtil.getPostRequest with Request.Builder().post().build() is implemented consistently.

core/src/main/java/com/predic8/membrane/balancer/client/LBNotificationClient.java (2)

23-37: LGTM: Import statements properly organized.

The import reorganization improves code structure and readability.


81-81: LGTM: Correct refactoring to Request.Builder pattern.

The replacement of MessageUtil.getPostRequest() with Request.Builder().post().build() maintains the same functionality while using the modern builder API.

core/src/main/java/com/predic8/membrane/core/interceptor/WSDLInterceptor.java (2)

116-116: LGTM: Proper exception declaration added.

The method signature correctly declares URISyntaxException, which can be thrown by Request.Builder().get().


118-118: LGTM: Correct refactoring to Request.Builder pattern.

The replacement of MessageUtil.getGetRequest() with Request.Builder().get().build() maintains the same functionality while using the modern builder API.

core/src/test/java/com/predic8/membrane/core/interceptor/formvalidation/FormValidationInterceptorTest.java (2)

18-18: LGTM: Proper imports added.

The imports for URISyntaxException and Request are correctly added to support the refactoring.

Also applies to: 23-23


65-67: LGTM: Proper exception handling and Request.Builder usage.

The method signature correctly declares URISyntaxException, and the replacement of MessageUtil.getGetRequest() with Request.Builder().get().build() is implemented correctly.

core/src/test/java/com/predic8/membrane/core/interceptor/WADLInterceptorTest.java (4)

20-20: LGTM! Import addition is correct.

The URISyntaxException import is necessary for the new Request.Builder pattern and is properly placed.


27-27: LGTM! Import addition is correct.

The Request import is necessary for the new Request.Builder pattern and is properly placed.


116-116: LGTM! Exception declaration is correct.

The method signature correctly declares URISyntaxException which is thrown by the Request.Builder().get().build() pattern.


118-118: LGTM! Request construction correctly updated.

The change from MessageUtil.getGetRequest() to Request.Builder().get().build() is correct and maintains the same functionality while using the new builder pattern.

core/src/test/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptorTest.java (4)

16-35: LGTM! Import reorganization is clean.

The imports are properly organized and all necessary imports for the refactored code are included.


68-69: LGTM! Test method correctly updated.

The method signature and request construction are properly updated to use the new Request.Builder pattern.


76-77: LGTM! Test method correctly updated.

The method signature and request construction are properly updated to use the new Request.Builder pattern.


86-87: LGTM! Test method correctly updated.

The method signature and request construction are properly updated to use the new Request.Builder pattern.

@predic8 predic8 merged commit ce5efb4 into master Aug 1, 2025
3 of 4 checks passed
@predic8 predic8 deleted the refactor-message-util branch August 1, 2025 12:26
This was referenced Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants