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

Error is not propagated. Mono hangs when StackOverflowError is thrown in map or flatMap #1118

Closed
0v1se opened this issue Mar 8, 2018 · 3 comments
Assignees
Labels
for/stackoverflow Questions are best asked on SO or Gitter type/enhancement A general enhancement
Milestone

Comments

@0v1se
Copy link

0v1se commented Mar 8, 2018

Expected behavior

StackOverFlow should be thrown

Actual behavior

java.lang.IllegalStateException: Timeout on blocking read for 5000 MILLISECONDS

Steps to reproduce

run strange method provided:

private void exception() {
    exception();
}

public void strange() {
    CompletableFuture<Integer> future = new CompletableFuture<>();
    future.complete(1);
    Mono<Integer> simple = Mono.fromFuture(future);//Mono.just(1)

    simple.map(r -> {
        exception();
        return r;
    }).block(Duration.ofSeconds(5));
}

Reactor Core version

3.1.5.RELEASE

JVM version (e.g. java -version)

java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

@smaldini smaldini added the for/stackoverflow Questions are best asked on SO or Gitter label Mar 9, 2018
@smaldini
Copy link
Contributor

smaldini commented Mar 9, 2018

StackOverflowError is considered a fatal error and falls into the general catch-all error from Hooks.onErrorDropped(consumer). We might want to clarify that @simonbasle

simonbasle added a commit that referenced this issue Mar 12, 2018
This commit makes the MonoCompletionStage drop errors that are thrown
inside the future.whenComplete block (which can happen with fatal
exceptions). Additionally, the default onErrorDropped behavior also logs
the dropped error.

This results in these errors being visible in the logs, where they were
previously swallowed by CompletionFuture.whenComplete.
@simonbasle
Copy link
Contributor

It is expected that a fatal error like StackOverflowError isn't propagated as an onError signal. However, what is not good in your case is that you don't see any trace of the error.

Looks like the error was swallowed by the CompletableFuture.whenComplete method :(

We made it so Mono.fromFuture will now explicitly "drop" the error (see the Hooks.onErrorDropped consumer). Additionally, the default behaviour of the error drop hook is now to log the dropped exception additionally to bubbling it up.

As a result, what you'd see after the fix is a timeout exception + logs of the stack overflow error.

@simonbasle simonbasle added the type/enhancement A general enhancement label Mar 13, 2018
@simonbasle simonbasle added this to the 3.2.0.RELEASE milestone Mar 13, 2018
@simonbasle simonbasle self-assigned this Mar 13, 2018
@0v1se
Copy link
Author

0v1se commented Mar 14, 2018

Ok. Thanks.

Also, such behaviour can be observed not only when CompletableFuture is used. It was only an example

simonbasle added a commit that referenced this issue Mar 19, 2018
This commit makes the MonoCompletionStage drop errors that are thrown
inside the future.whenComplete block (which can happen with fatal
exceptions). Additionally, the default onErrorDropped behavior also logs
the dropped error.

This results in these errors being visible in the logs, where they were
previously swallowed by CompletionFuture.whenComplete.

This is a backport of #1126 (commit 7e29da8), as tracked in #1111
@simonbasle simonbasle modified the milestones: 3.2.0.RELEASE, 3.2.0.M2 May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for/stackoverflow Questions are best asked on SO or Gitter type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants