Skip to content

Fix: HttpServletHandler: Request.create() caused build failure#2604

Merged
predic8 merged 3 commits into
masterfrom
fix-master
Jan 13, 2026
Merged

Fix: HttpServletHandler: Request.create() caused build failure#2604
predic8 merged 3 commits into
masterfrom
fix-master

Conversation

@christiangoerdes

@christiangoerdes christiangoerdes commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Improved HTTP request handling with enhanced protocol validation.
    • Extended request builder with additional fluent configuration methods.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added two fluent-builder methods (uri and version) to Request.Builder to enhance method chaining capabilities. Refactored HttpServletHandler to extract a new helper method that validates HTTP protocol and builds Request objects using the builder pattern, delegating from the existing createRequest method.

Changes

Cohort / File(s) Summary
Request Builder Enhancement
core/src/main/java/com/predic8/membrane/core/http/Request.java
Added fluent-builder methods uri(String uri) and version(String version) to Request.Builder for improved method chaining in request construction.
HTTP Servlet Request Creation
war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java
Extracted new helper method createRequest(String method, String uri, String protocol, Header header, InputStream in) that validates HTTP protocol and builds Request via Builder; refactored existing createRequest() to delegate to the new method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • #2033: Modifies Request.Builder in the same Request class with potential overlapping concerns around builder pattern enhancements.

Suggested reviewers

  • predic8

Poem

🐰✨ A builder hops with grace,
New methods join the race,
Protocol validated, clean and bright,
Requests now chain with delight! 🎀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing a build failure in HttpServletHandler caused by Request.create() removal by refactoring to use Request.Builder.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@membrane-ci-server

Copy link
Copy Markdown

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

@christiangoerdes

Copy link
Copy Markdown
Collaborator Author

/ok-to-test

…tHandler` to improve clarity and retain functionality.
@christiangoerdes christiangoerdes changed the title Undo Request.create() removal: Method was used by HttpServletHandler and caused build failure Fix: HttpServletHandler: Request.create() caused build failure Jan 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java (1)

134-145: Consider reducing visibility and avoiding parameter shadowing.

The new helper method correctly constructs a Request from the given parameters. Two minor observations:

  1. Visibility: The method is public but only called internally. If external access isn't needed, consider reducing to package-private to minimize API surface.

  2. Parameter naming: The local request parameter shadows the class field this.request (of type HttpServletRequest). While the types differ and won't cause compilation issues, renaming to req or result could improve clarity.

♻️ Optional refactor
-	public Request createRequest(String method, String uri, String protocol, Header header, InputStream in) throws IOException {
-		Request request = new Request();
-		request.setMethod(method);
-		request.setUri(uri);
+	Request createRequest(String method, String uri, String protocol, Header header, InputStream in) throws IOException {
+		Request req = new Request();
+		req.setMethod(method);
+		req.setUri(uri);
 		if (!protocol.startsWith("HTTP/"))
 			throw new RuntimeException("Unknown protocol '" + protocol + "'");
-		request.setVersion(protocol.substring(5));
-		request.setHeader(header);
+		req.setVersion(protocol.substring(5));
+		req.setHeader(header);
 
-		request.createBody(in);
-		return request;
+		req.createBody(in);
+		return req;
 	}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7494ff8 and 40a5326.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/http/Message.java
  • core/src/main/java/com/predic8/membrane/core/http/Response.java
  • war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-19T11:12:26.787Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2156
File: core/src/main/java/com/predic8/membrane/core/openapi/validators/QueryParameterValidator.java:129-131
Timestamp: 2025-09-19T11:12:26.787Z
Learning: Request.get().path() in com.predic8.membrane.core.openapi.model.Request preserves the query string portion of the path, so URIFactory.createWithoutException(request.getPath()).getQuery() correctly extracts query parameters.

Applied to files:

  • war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (4)
core/src/main/java/com/predic8/membrane/core/http/Message.java (1)

167-206: LGTM - visibility change is appropriate.

Changing createBody(InputStream in) from protected to public enables external callers (like HttpServletHandler in the war module) to construct request/response bodies. This aligns with the PR objective of moving Request.create() logic into HttpServletHandler.

core/src/main/java/com/predic8/membrane/core/http/Response.java (1)

424-430: LGTM - visibility change maintains override contract.

The createBody(InputStream in) override must match or exceed the visibility of the parent Message.createBody(). Since the parent is now public, this override correctly follows suit.

war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java (2)

32-32: LGTM - necessary import for new method signature.


126-132: LGTM - clean delegation to the new helper method.

The refactored createRequest() correctly extracts all necessary parameters from HttpServletRequest and delegates to the new helper.

…HttpServletHandler.createRequest()` to use Builder for improved readability and maintainability.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java (1)

134-145: Well-structured builder-based request construction.

The protocol validation at line 135-136 correctly guards the substring(5) call. The builder chain clearly expresses the request assembly.

Two minor observations:

  1. Visibility: The method is public but the enclosing class is package-private. If this is solely for testability, consider keeping it package-private to match the class scope.

  2. Exception type: Consider using IllegalArgumentException instead of RuntimeException for the invalid protocol case, as it better communicates that the input is invalid.

Optional: Use IllegalArgumentException for clearer semantics
 public Request createRequest(String method, String uri, String protocol, Header header, InputStream in) {
     if (!protocol.startsWith("HTTP/"))
-        throw new RuntimeException("Unknown protocol '" + protocol + "'");
+        throw new IllegalArgumentException("Unknown protocol '" + protocol + "'");

     return new Request.Builder()
             .method(method)
             .uri(uri)
             .header(header)
             .body(in)
             .version(protocol.substring(5))
             .build();
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40a5326 and 4c5983a.

📒 Files selected for processing (2)
  • core/src/main/java/com/predic8/membrane/core/http/Request.java
  • war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: predic8
Repo: membrane/api-gateway PR: 2156
File: core/src/main/java/com/predic8/membrane/core/openapi/validators/QueryParameterValidator.java:129-131
Timestamp: 2025-09-19T11:12:26.787Z
Learning: Request.get().path() in com.predic8.membrane.core.openapi.model.Request preserves the query string portion of the path, so URIFactory.createWithoutException(request.getPath()).getQuery() correctly extracts query parameters.
📚 Learning: 2025-09-19T11:12:26.787Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2156
File: core/src/main/java/com/predic8/membrane/core/openapi/validators/QueryParameterValidator.java:129-131
Timestamp: 2025-09-19T11:12:26.787Z
Learning: Request.get().path() in com.predic8.membrane.core.openapi.model.Request preserves the query string portion of the path, so URIFactory.createWithoutException(request.getPath()).getQuery() correctly extracts query parameters.

Applied to files:

  • war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
core/src/main/java/com/predic8/membrane/core/http/Request.java (1)

252-260: LGTM! Clean fluent builder additions.

Both methods follow the established pattern of other builder methods in this class (e.g., method(), header()). The uri() method provides a simpler alternative to url(URIFactory, String) when the path/query is already extracted, and version() allows overriding the default "1.1" set in the constructor.

war/src/main/java/com/predic8/membrane/servlet/embedded/HttpServletHandler.java (1)

126-132: Clean delegation to the new builder-based method.

The refactoring properly extracts the request construction logic while maintaining the existing behavior for path/query assembly and context root handling.

@predic8 predic8 merged commit 4d7c315 into master Jan 13, 2026
4 of 5 checks passed
@predic8 predic8 deleted the fix-master branch January 13, 2026 09:19
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