-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Introduce QuarkusBindException #23186
Conversation
This exception is used to record the actual ports that cause binding conflicts, thus allowing Quarkus to properly inform the user of which port(s) caused conflicts instead of guessing based on what the provided configuration. Fixes: quarkusio#22967
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Note that every server (TCP server) could use this mechanism.
Throwable effectiveCause = event.cause(); | ||
if (effectiveCause instanceof BindException) { | ||
if ((sslConfig == null) && (httpServerOptions != null)) { | ||
effectiveCause = new QuarkusBindException(httpServerOptions.getPort()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would that work for negative ports (negative ports in Vert. x are random ports but all the verticles use the same port, unlike the port 0 which is random every time). I guess it's fine as it would indicate the negative port (like -1) and it's up to the user to check in the config which one it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, although this is an edge case which I am going to guess we won't see often, if ever :)
I think we would probably just handle it when printing the helper messages if the exception fails.
Yes absolutely. This can and should be extended further |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Pretty much what I had in mind. 👍
Just one minor suggestion.
|
||
public QuarkusBindException(List<Integer> ports) { | ||
if (ports.isEmpty()) { | ||
throw new IllegalStateException("ports must not be empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, this is surely very unexpected, but wouldn't it be confusing for the user if he got that instead of e.g. Port ? seems to be in use by another process.
(note the ?
instead of the actual port)?
Might be better to add this as a suppressed exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that suppression doesn't work as the exception is not (fully) logged. So maybe just a warning?
IDK, really just a minor thing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I added this check is that I wanted to guard against erroneous usage and not have to deal with empty ports when inspecting the exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense. But if it really kicks in and a user is faced with it, then it will be more puzzling.
I guess in the end it's more of a "quarkus developer" guard than anything that will ever pop up for an actual quarkus user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly! It's meant to be used by Quarkus developers (as it's part of the runtime package, so not meant to be part of the public API)
I won't backport this tonight, let's keep it for 2.7.1.Final. |
This exception is used to record the actual ports that
cause binding conflicts, thus allowing Quarkus to properly
inform the user of which port(s) caused conflicts
instead of guessing based on what the provided configuration.
Fixes: #22967
P.S. We could probably extend this even more in the future to provide the configuration property involved as well as the name of the "service" that tried to bind