-
Notifications
You must be signed in to change notification settings - Fork 157
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
TimeoutException instead of CancellationException on timeout #1031
Conversation
|
||
/** | ||
* This is an internal class and is only public for access. | ||
*/ | ||
public class NatsRequestCompletableFuture extends CompletableFuture<Message> { | ||
public static final boolean USE_TIMEOUT_EXCEPTION = Boolean.getBoolean(System.getProperty("nats.use-timeout-exception")); // TODO: Remove. Use TimeoutException instead of CancellationException. |
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.
Can we add nats.use-timeout-exception
in the Option class
public static final String PROP_USE_TIMEOUT_EXCEPTION = PFX + "use.timeout.exception";
This will also mean that you will have to modify the NatsRequestCompletableFuture
constructor to receive the setting from the connection and then change NatsConnection
line 1170
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.
done. however, it would be nice if you labeled these changes as temporary to support legacy. in the next version, it's preferable to use TimeoutException without additional questions, IMO.
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'm okay with adding a comment to make this the default in future versions.
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.
Looks good except for nitpicks.
* Get whether to throw {@link java.util.concurrent.TimeoutException} on timeout instead of {@link java.util.concurrent.CancellationException}. | ||
* @return the flag | ||
*/ | ||
public boolean isUseTimeoutException() { |
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.
To be more consistent with other booleans in this class, please use useTimeoutException
no is
|
||
public boolean isUseTimeoutException() { | ||
return useTimeoutException; | ||
} |
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.
you don't need this method.
@maximbreitman Please update your branch. Also tests in |
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
It would be nice to take the first step in this direction - #797
Since this change is still "breaking", we can make it optional until next version