Search in sources :

Example 1 with CloseEventObservedException

use of io.servicetalk.transport.netty.internal.CloseHandler.CloseEventObservedException in project servicetalk by apple.

the class GracefulConnectionClosureHandlingTest method assertClosedChannelException.

private void assertClosedChannelException(Executable runnable, CloseEvent expectedCloseEvent) {
    Exception e = assertThrows(ExecutionException.class, runnable);
    Throwable cause = e.getCause();
    assertThat(cause, anyOf(instanceOf(ClosedChannelException.class), instanceOf(IOException.class)));
    if (protocol == HTTP_2) {
        // HTTP/2 does not enhance ClosedChannelException with CloseEvent
        return;
    }
    while (cause != null && !(cause instanceof CloseEventObservedException)) {
        cause = cause.getCause();
    }
    assertThat("Exception is not enhanced with CloseEvent", cause, is(notNullValue()));
    assertThat(((CloseEventObservedException) cause).event(), is(expectedCloseEvent));
}
Also used : CloseEventObservedException(io.servicetalk.transport.netty.internal.CloseHandler.CloseEventObservedException) PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) CloseEventObservedException(io.servicetalk.transport.netty.internal.CloseHandler.CloseEventObservedException) ClosedChannelException(java.nio.channels.ClosedChannelException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

CloseEventObservedException (io.servicetalk.transport.netty.internal.CloseHandler.CloseEventObservedException)1 PlatformDependent.throwException (io.servicetalk.utils.internal.PlatformDependent.throwException)1 IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 ExecutionException (java.util.concurrent.ExecutionException)1