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

Reactive Eval::get should propagate errors #989

Closed
johnmcclean opened this issue Nov 27, 2018 · 2 comments
Closed

Reactive Eval::get should propagate errors #989

johnmcclean opened this issue Nov 27, 2018 · 2 comments
Labels
Milestone

Comments

@johnmcclean
Copy link
Member

Currently, for reactive/ CompletableEvals Eval get() swallows any errors recieved via the reactive-streams error channel (but propagates errors thrown inside it's own operators). It returns null instead.

This is a bug. It is reasonable to expect that round triping from a Future with a NoSuchElementException results in a failed Future with a NullPointerException and not a successful Future with a null value.

Eval::get should throw any errors recieved from any Publisher to which it was subscribed (this does make mixing Eval with reactive-streams operators fromPublisher / mergeMap unsafe, likely for the duration of the 10.X.X cycle).

@johnmcclean johnmcclean added this to the 10.1.1 milestone Nov 27, 2018
@johnmcclean
Copy link
Member Author

Tests

@Test(expected = NoSuchElementException.class)
     public void fromFuture(){
      Future<Integer> f = Future.ofError(new NoSuchElementException());

      Eval.fromPublisher(f).get();


    }

    @Test
    public void toTry(){
        Future<Integer> f = Future.ofError(new NoSuchElementException());
        Try<Integer, Throwable> t = Eval.fromPublisher(f).toTry();
        System.out.println(t);
        assertThat(t.isFailure(),equalTo(true));
        assertThat(t.failureGet().orElse(null),instanceOf(NoSuchElementException.class));
    }
    @Test
    public void fromFuture2(){
        AtomicReference<Throwable> error = new AtomicReference<>(null);
        Future<Integer> f = Future.ofError(new NoSuchElementException());
        Future.fromPublisher(Eval.fromPublisher(f)).recover(e->{
            error.set(e.getCause());return -1;
        });

        assertThat(error.get(),instanceOf(NoSuchElementException.class));
    }

@johnmcclean
Copy link
Member Author

Released in 10.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant