@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); handler.deactivateStream(); throw re; } else if (bytesRead == byteCount) { handler.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; }
@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); handler.deactivateStream(); throw re; } else if (bytesRead == byteCount) { handler.deactivateStream(); callback.onComplete(streamId); } return bytesRead != byteCount; }