@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
.last(true) .build(); buffer.allowBufferDispose(false); ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null));
while (!last) { Buffer buffer = mm.allocate(PayloadGenerator.MAX_CHUNK_SIZE); buffer.allowBufferDispose(true); final long readBytes = bodyLocal.read(buffer.toByteBuffer()); if (readBytes > 0) {
private Buffer getHeader() { final Buffer headerToWrite = header.duplicate(); headerToWrite.allowBufferDispose(false); return headerToWrite; }
private void checkCurrentBuffer() { if (currentBuffer == null) { currentBuffer = memoryManager.allocate(bufferSize); currentBuffer.allowBufferDispose(true); } }
buffer.allowBufferDispose(true);
private static Buffer allowDispose(final Buffer buffer) { buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
public static Buffer allowDispose(final Buffer buffer) { if (buffer == null) { return null; } buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
public static Buffer getLongAsBuffer(final MemoryManager memoryManager, final long length) { final Buffer b = memoryManager.allocate(20); b.allowBufferDispose(true); HttpUtils.longToBuffer(length, b); return b; }
public static Buffer allowDispose(final Buffer buffer) { if (buffer == null) { return null; } buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
private static Buffer allowDispose(final Buffer buffer) { buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
private static Buffer allowDispose(final Buffer buffer) { buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
public static Buffer allowDispose(final Buffer buffer) { if (buffer == null) { return null; } buffer.allowBufferDispose(true); if (buffer.isComposite()) { ((CompositeBuffer) buffer).allowInternalBuffersDispose(true); } return buffer; }
protected void updateInputContentBuffer(final Buffer buffer) { buffer.allowBufferDispose(true); if (inputContentBuffer == null) { inputContentBuffer = buffer; } else if (inputContentBuffer.hasRemaining() || readAheadLimit > 0) { // if the stream is marked - we can't dispose the inputContentBuffer, even if it's been read off toCompositeInputContentBuffer().append(buffer); } else { inputContentBuffer.tryDispose(); inputContentBuffer = buffer; } }
protected void updateInputContentBuffer(final Buffer buffer) { buffer.allowBufferDispose(true); if (inputContentBuffer == null) { inputContentBuffer = buffer; } else if (inputContentBuffer.hasRemaining() || readAheadLimit > 0) { // if the stream is marked - we can't dispose the inputContentBuffer, even if it's been read off toCompositeInputContentBuffer().append(buffer); } else { inputContentBuffer.tryDispose(); inputContentBuffer = buffer; } }
private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) { if (currentBuffer != null) { currentBuffer.dispose(); } if (bigBuffer != null) { bigBuffer.allowBufferDispose(true); if (bigBuffer.isComposite()) { ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true); } bigBuffer.dispose(); } }
private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) { if (currentBuffer != null) { currentBuffer.dispose(); } if (bigBuffer != null) { bigBuffer.allowBufferDispose(true); if (bigBuffer.isComposite()) { ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true); } bigBuffer.dispose(); } }
private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) { if (currentBuffer != null) { currentBuffer.dispose(); } if (bigBuffer != null) { bigBuffer.allowBufferDispose(true); if (bigBuffer.isComposite()) { ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true); } bigBuffer.dispose(); } }
@SuppressWarnings("unchecked") protected void sendRaw(byte[] rawData) { final Connection connection = protocolHandler.getConnection(); final MemoryManager mm = connection.getTransport().getMemoryManager(); final Buffer buffer = Buffers.wrap(mm, rawData); buffer.allowBufferDispose(false); connection.write(buffer); }