Search in sources :

Example 1 with RetryableException

use of io.servicetalk.transport.api.RetryableException in project servicetalk by apple.

the class DefaultNettyConnection method enrichError.

private Throwable enrichError(final Throwable t) {
    Throwable throwable;
    CloseEvent closeReason;
    if (t instanceof AbortedFirstWriteException) {
        if ((closeReason = this.closeReason) != null) {
            throwable = new RetryableClosedChannelException(wrapWithCloseReason(closeReason, t.getCause()));
        } else if (t.getCause() instanceof RetryableException) {
            // Unwrap additional layer of RetryableException if the cause is already retryable
            throwable = t.getCause();
        } else if (t.getCause() instanceof ClosedChannelException) {
            throwable = new RetryableClosedChannelException((ClosedChannelException) t.getCause());
        } else {
            throwable = t;
        }
    } else if (t instanceof RetryableClosedChannelException) {
        throwable = t;
    } else {
        if ((closeReason = this.closeReason) != null) {
            throwable = wrapWithCloseReason(closeReason, t);
        } else {
            throwable = enrichProtocolError.apply(t);
        }
    }
    transportError.onSuccess(throwable);
    return throwable;
}
Also used : CloseEvent(io.servicetalk.transport.netty.internal.CloseHandler.CloseEvent) ClosedChannelException(java.nio.channels.ClosedChannelException) RetryableException(io.servicetalk.transport.api.RetryableException) AbortedFirstWriteException(io.servicetalk.transport.netty.internal.WriteStreamSubscriber.AbortedFirstWriteException)

Aggregations

RetryableException (io.servicetalk.transport.api.RetryableException)1 CloseEvent (io.servicetalk.transport.netty.internal.CloseHandler.CloseEvent)1 AbortedFirstWriteException (io.servicetalk.transport.netty.internal.WriteStreamSubscriber.AbortedFirstWriteException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1