-
Notifications
You must be signed in to change notification settings - Fork 357
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
Better handling of MicroProfile Rest Client Proxies #4918
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MicroProfile provides just a host and a port, yet the connectors expect to be able to read this as a URI. The TCK supplies the host as just "localhost" which the current connectors won't handle, since the lack of a preceding "http://" or equivalent means that the "localhost" gets picked up as the scheme and not the host. Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
jansupol
approved these changes
Dec 1, 2021
senivam
approved these changes
Dec 2, 2021
This was referenced Jun 14, 2022
Closed
1 task
This was referenced Jun 18, 2022
1 task
This was referenced Feb 11, 2023
Closed
1 task
This was referenced May 11, 2023
This was referenced Jun 1, 2023
This was referenced Jun 4, 2023
This was referenced Jun 15, 2023
This was referenced Jul 6, 2023
This was referenced Aug 28, 2023
This was referenced Jan 16, 2024
1 task
1 task
This was referenced Apr 13, 2024
Closed
1 task
This was referenced Feb 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The MicroProfile Rest Client API asks a user to provide just a hostname and a port.
When this is provided to the various connectors which support proxy configuration via
ClientProperties.PROXY_URI
they will fail to translate this if something simple such aslocalhost:8765
is provided (as the MicroProfile Rest Client TCK does).https://github.com/eclipse-ee4j/jersey/blob/master/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java#L281
This is because they attempt to convert the given string to a URI and then parse details from it using URI methods. So a proxy config from MicroProfile Rest Client of
localhost:8765
would at the moment be given as-is, and when converted to a URI will result in the host being null and the scheme being set tolocalhost
, leading to an error further down the line.This change attempts to resolve this by simply defaulting to HTTP if no schema is given by essentially doing the same check as the connectors earlier on, resulting in the same string from MicroProfile Rest Client becoming
http://localhost:8765
. I've tried to account for IP addresses as well as host names (since the MicroProfile spec says to support them), but yell if I've missed an acceptable URI format.Tested on Jersey 2.34 using MicroProfile Rest Client 2.0 TCK with Apache HTTP Client connector (since default Jersey connector doesn't support proxy config in this manner). Not current master or latest 3.0 of MicroProfile Rest Client, but just from eyeballing it none of these bits of code seem to have changed.