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

TimeoutException instead of CancellationException on timeout #1031

Merged
merged 4 commits into from
Nov 1, 2023

Conversation

breitone
Copy link
Contributor

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


/**
* 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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@scottf scottf left a 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() {
Copy link
Contributor

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;
}
Copy link
Contributor

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.

@scottf
Copy link
Contributor

scottf commented Oct 31, 2023

@maximbreitman Please update your branch. Also tests in RequestTests.java need to be fixed. Is there any way to test this?

@breitone breitone requested a review from scottf October 31, 2023 12:34
Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

@scottf scottf merged commit f83f360 into nats-io:main Nov 1, 2023
1 check passed
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.

None yet

2 participants