I’m having a bit of troubles understanding the default behavior of a streaming ServiceCall:
// Definition
ServiceCall<Source<String, NotUsed>, Done> doSomething();
// Implementation
public ServiceCall<Source<String, NotUsed>, Done> doSomething() {
return source -> {
throw new TransportException(TransportErrorCode.InternalServerError, new ExceptionMessage("Internal server error", "..."));
};
}
The consumer of this server however, never sees the TransportException
@Test
public void testShouldFail() {
MyService service = server.client(MyService.class);
Source<String, NotUsed> input = Source.empty();
CompletableFuture<Done> future = service.doSomething().invoke(input).toCompletableFuture();
ServiceTest.eventually(FiniteDuration.apply(5, SECONDS), () -> {
assertThat(future.isCompletedExceptionally()).isTrue();
});
}
I have the feeling that it has to do with some magic running under the hood, because when I move the TransportException
outside of the lambda, the future fails as expected.
Is there anything I’m missing here?