@Override public void exceptionCaught(Throwable cause) throws Exception { deactivateStream(); callback.onFailure(streamId, cause); }
StreamCallback callback = entry.getValue(); if (resp.byteCount > 0) { StreamInterceptor<ResponseMessage> interceptor = new StreamInterceptor<>( this, resp.streamId, resp.byteCount, callback); try {
StreamCallback callback = entry.getValue(); if (resp.byteCount > 0) { StreamInterceptor interceptor = new StreamInterceptor(this, resp.streamId, resp.byteCount, callback); try {
StreamCallback callback = entry.getValue(); if (resp.byteCount > 0) { StreamInterceptor<ResponseMessage> interceptor = new StreamInterceptor<>( this, resp.streamId, resp.byteCount, callback); try {
@Override public void channelInactive() throws Exception { deactivateStream(); callback.onFailure(streamId, new ClosedChannelException()); }
if (callback != null) { if (resp.byteCount > 0) { StreamInterceptor interceptor = new StreamInterceptor(this, resp.streamId, resp.byteCount, callback); try {
@Override public void exceptionCaught(Throwable cause) throws Exception { deactivateStream(); callback.onFailure(streamId, cause); }
StreamInterceptor<RequestMessage> interceptor = new StreamInterceptor<>( this, wrappedCallback.getID(), req.bodyByteCount, wrappedCallback); frameDecoder.setInterceptor(interceptor);
@Override public void channelInactive() throws Exception { deactivateStream(); callback.onFailure(streamId, new ClosedChannelException()); }
StreamInterceptor<RequestMessage> interceptor = new StreamInterceptor<>( this, wrappedCallback.getID(), req.bodyByteCount, wrappedCallback); frameDecoder.setInterceptor(interceptor);
@Override public boolean handle(ByteBuf buf) throws Exception { int toRead = (int) Math.min(buf.readableBytes(), byteCount - bytesRead); ByteBuffer nioBuffer = buf.readSlice(toRead).nioBuffer(); int available = nioBuffer.remaining(); callback.onData(streamId, nioBuffer); bytesRead += available; if (bytesRead > byteCount) { RuntimeException re = new IllegalStateException(String.format( "Read too many bytes? Expected %d, but read %d.", byteCount, bytesRead)); callback.onFailure(streamId, re); deactivateStream(); throw re; } else if (bytesRead == byteCount) { deactivateStream(); callback.onComplete(streamId); } return bytesRead != byteCount; }
@Override public boolean handle(ByteBuf buf) throws Exception { int toRead = (int) Math.min(buf.readableBytes(), byteCount - bytesRead); ByteBuffer nioBuffer = buf.readSlice(toRead).nioBuffer(); int available = nioBuffer.remaining(); callback.onData(streamId, nioBuffer); bytesRead += available; if (bytesRead > byteCount) { RuntimeException re = new IllegalStateException(String.format( "Read too many bytes? Expected %d, but read %d.", byteCount, bytesRead)); callback.onFailure(streamId, re); deactivateStream(); throw re; } else if (bytesRead == byteCount) { deactivateStream(); callback.onComplete(streamId); } return bytesRead != byteCount; }