-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Behaviour of doFinally #951
Comments
That's not what I see, the second example goes through Modifying @Test
public void errorBeforeAndAfterFinallyTest() {
System.err.println("> error before finally");
Mono.just(true)
.map(this::throwError)
.doFinally(this::doFinalThing)
.subscribe(v -> {}, e -> {});
System.err.println("> error after finally");
Mono.just(true)
.doFinally(this::doFinalThing)
.map(this::throwError)
.subscribe(v -> {}, e -> {});
} I get the following output:
|
Thank you for the clarification! |
Hi, I'm commenting in that because I think there is still an issue on the doFinally. @Test
public void withoutConsumerInSubscribe() {
System.err.println("> subscribe without consumer: map_doOnError_doFinally");
Mono.just(true)
.map(this::throwError)
.doOnError(e -> System.err.println("doOnError"))
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.subscribe();
System.err.println("> subscribe without consumer: doFinally_map_doOnError");
Mono.just(true)
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.map(this::throwError)
.doOnError(e -> System.err.println("doOnError"))
.subscribe();
System.err.println("> subscribe without consumer: map_doFinally_doOnError");
Mono.just(true)
.map(this::throwError)
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.doOnError(e -> System.err.println("doOnError"))
.subscribe();
}
@Test
public void withConsumerInSubscribe() {
System.err.println("> subscribe with consumer: map_doOnError_doFinally");
Mono.just(true)
.map(this::throwError)
.doOnError(e -> System.err.println("doOnError"))
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.subscribe(v -> { }, e -> { });
System.err.println("> subscribe with consumer: doFinally_map_doOnError");
Mono.just(true)
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.map(this::throwError)
.doOnError(e -> System.err.println("doOnError"))
.subscribe(v -> { }, e -> { });
System.err.println("> subscribe with consumer: map_doFinally_doOnError");
Mono.just(true)
.map(this::throwError)
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.doOnError(e -> System.err.println("doOnError"))
.subscribe(v -> { }, e -> { });
}
@Test
public void whithoutDoOnError() {
System.err.println("> whithoutDoOnError");
Mono.just(true)
.map(this::throwError)
.doFinally(any -> System.err.println("doFinally " + any.toString()))
.subscribe();
}
private Boolean throwError(Boolean x) {
throw new IllegalStateException();
} the produce
As you can see, when using Also, I upgraded from 3.0.7 to 3.1.2 and its not possible to write the code from Reactor Core version3.1.2 |
Thanks for the demonstration @baptistemesta. Not sure what you mean by "it is not possible to write..." (copy-pasted the whole code in a test and it worked fine from a compilation point of view). Indeed the case where no error handler is provided in This is due to the subscribe throwing an |
This commit wraps the application of doFinally's handler in a try/finally block, so that in the case where a final subscriber throws (typically because no error handler was defined), it still executes the doFinally handler.
That was fast :) |
well the second repro case was a huge help, so thanks for providing that ;) 👍 |
BTW when I was saying |
I just spent 3 hrs trying to debug why I'm getting Schematically my code looks like this:
|
@unoexperto Please provide a complete reproducer (that we can run locally) either as an issue if you think you're facing a bug, or as a question on stackoverflow (https://stackoverflow.com/questions/tagged/project-reactor). |
Expected behavior
According to the javadoc shouldn't be both tests have the same log output?
Actual behavior
Steps to reproduce
See code above
Reactor Core version
3.1.1
JVM version (e.g.
java -version
)java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
OS version (e.g.
uname -a
)MINGW64_NT-10.0
The text was updated successfully, but these errors were encountered: