@Override
    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
        // if this happens enough times (like the client is unable to deserialize a response) the pending
        // messages queue will not clear.  wonder if there is some way to cope with that.  of course, if
        // there are that many failures someone would take notice and hopefully stop the client.
        logger.error("Could not process the response", cause);

        final ResultQueue pendingQueue = pending.getAndSet(null);
        if (pendingQueue != null) pendingQueue.markError(cause);

        if (ExceptionHelper.getRootCause(cause) instanceof SSLException) {
            // inbound ssl error can happen with tls 1.3 because client certification auth can fail after the handshake completes
            // store the inbound ssl error so that outbound can retrieve it
            ctx.channel().attr(INBOUND_SSL_EXCEPTION).set(cause);
        }

        // serialization exceptions should not close the channel - that's worth a retry
        if (!IteratorUtils.anyMatch(ExceptionUtils.getThrowableList(cause).iterator(), t -> t instanceof SerializationException))
            if (ctx.channel().isActive()) ctx.close();
    }
Takes a map of requests pending responses and writes responses to the {@link ResultQueue} of a request
as the {@link ResponseMessage} objects are deserialized.
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/GremlinResponseHandler.java