Skip to content

Conversation

@jpallas
Copy link
Contributor

@jpallas jpallas commented Jan 20, 2026

Change in handling of URIs by HttpClient.

@jpallas jpallas requested a review from Copilot January 20, 2026 04:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes HTTP client port handling issues in Vert.x 4 when making requests to URLs with non-standard ports. The change addresses a problem where HttpClient.request(method, url) doesn't properly parse port numbers from URLs, causing connection failures to services running on non-standard ports.

Changes:

  • Updated FakeAuthenticator and OidcKeycloakAuthenticator to use RequestOptions with setAbsoluteURI() instead of passing URL strings directly to HttpClient.request()
  • Added comprehensive test suite demonstrating the port parsing issue and validating the fix

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
FakeAuthenticator.java Modified HTTP client request to use RequestOptions with setAbsoluteURI for proper port parsing
OidcKeycloakAuthenticator.java Modified HTTP client request to use RequestOptions with setAbsoluteURI for proper port parsing
FakeAuthenticatorHttpClientTest.java Added new test class with two tests validating HTTP client port handling with non-standard ports

private static final Logger log = LoggerFactory.getLogger(FakeAuthenticatorHttpClientTest.class);
private Vertx vertx;
private HttpClient client;
private int port = 8899; // Non-standard port to test port handling
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The hardcoded port number may cause test failures if port 8899 is already in use. Consider using a dynamic port assignment (port 0) and retrieving the actual port from the server after it starts, which is a common pattern in Vert.x testing.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 155 to 163
} else if (response2.statusCode() == 302 || response2.statusCode() == 200) {
log.info("Test passed: Token endpoint was successfully reached");
async.complete();
} else {
// Some other error, but not a port issue
log.info("Got response code {} which indicates the port was reached",
response2.statusCode());
async.complete();
}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The test completes successfully for any response code other than a connection refused error, including error codes that might indicate actual problems (e.g., 400, 404). The test should have more specific assertions about what constitutes a successful outcome rather than accepting any response that reaches the server.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI commented Jan 20, 2026

@jpallas I've opened a new pull request, #116, to work on those changes. Once the pull request is ready, I'll request review from you.

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