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

Fix invalid proxy setting when the port ends with a whitespace #44708

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

IvanBaricic
Copy link

Scenario:

A user configures the proxy address (for example in application.properties, .env file etc) and there is a whitespace at the end of the settings like here:

'quarkus.rest-client.proxy-address=localhost:8080 '

Error:

After splitting the proxy address, part with the port is a string value like "8080 " and Integer.parseInt("8080 ") will throw a NumberFormatException:

Invalid proxy setting. The port is not a number in 'localhost:8080 '

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request! That's indeed something that needs fixing.

Actually, what we should do is fix the config property using @WithConverter(TrimmedStringConverter.class) instead. That way it's fixed at the source once and for all and we don't have to think about trimming it at all.

There might be other properties there for which it makes sense to use it.

Would you be interested in adjusting your patch to do that instead?

@IvanBaricic IvanBaricic force-pushed the main branch 2 times, most recently from a46e8e6 to 39a5776 Compare November 27, 2024 06:27
@IvanBaricic IvanBaricic force-pushed the main branch 2 times, most recently from b6ef7c4 to 13a3a24 Compare November 27, 2024 12:37
@IvanBaricic
Copy link
Author

Thanks for your hint! I have added this annotation to proxyAddress configuration property. I personally find only this one to be useful, .. due to parsing a number from the string.

This is my very first commitment to Quarkus framework, .. so I hope, I am done it properly.

gastaldi
gastaldi previously approved these changes Nov 27, 2024
Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR!

@gastaldi gastaldi added triage/waiting-for-ci Ready to merge when CI successfully finishes and removed area/rest-client area/rest labels Nov 27, 2024
gsmet
gsmet previously requested changes Nov 27, 2024
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Sorry, I had an hesitation before approving and I checked in our code base and for the new @ConfigMapping config framework, the annotation should be added in the container instead of on the property.

So if you can just make this tiny change, check that everything is OK on your side with this change, and amend your commit, that would be awesome!

Comment on lines 63 to 64
@WithConverter(TrimmedStringConverter.class)
Optional<String> proxyAddress();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@WithConverter(TrimmedStringConverter.class)
Optional<String> proxyAddress();
Optional<@WithConverter(TrimmedStringConverter.class) String> proxyAddress();

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your hint, .. I am sorry, I am too late, .. geoand has already changed it and merge the pull request into quarkusio:main. Great! If I look after the same annotation & Optional, I find 38x occurrences in the codebase; so theoretical I could refactor them to use the same approach everywhere, could not I.

Copy link

github-actions bot commented Nov 27, 2024

🎊 PR Preview 3ac8d23 has been successfully built and deployed to https://quarkus-pr-main-44708-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

This comment has been minimized.

@gastaldi
Copy link
Contributor

Nice catch, also, here is a real example using it:

Optional<@WithConverter(TrimmedStringConverter.class) List<String>> forwardParams();

@gastaldi gastaldi dismissed their stale review November 27, 2024 14:05

Waiting for the change above

This comment has been minimized.

@gastaldi gastaldi removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Nov 27, 2024
@geoand
Copy link
Contributor

geoand commented Nov 29, 2024

Thanks for this!

I updated the PR so it should be good to go now

@geoand geoand dismissed gsmet’s stale review November 29, 2024 09:19

comment addressed

Copy link

quarkus-bot bot commented Nov 29, 2024

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 2654019.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Nov 29, 2024
Copy link

quarkus-bot bot commented Nov 29, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 2654019.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@geoand geoand merged commit da9fbf0 into quarkusio:main Nov 29, 2024
34 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Nov 29, 2024
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Nov 29, 2024
@gsmet gsmet modified the milestones: 3.18 - main, 3.17.3 Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants