public long read(final ByteBuffer[] dsts) throws IOException { final StreamSourceChannel channel = this.channel; if (channel == null) { return -1L; } return channel.read(dsts); }
public int read(final ByteBuffer dst) throws IOException { final StreamSourceChannel channel = this.channel; if (channel == null) { return -1; } return channel.read(dst); }
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException { final StreamSourceChannel channel = this.channel; if (channel == null) { return -1L; } return channel.read(dsts, offset, length); }
public int read(final ByteBuffer dst) throws IOException { return channel.read(dst); }
public long read(final ByteBuffer[] dsts) throws IOException { return delegate.read(dsts); }
public long read(final ByteBuffer[] dsts, final int offs, final int len) throws IOException { return channel.read(dsts, offs, len); }
public int read(final ByteBuffer dst) throws IOException { return source.read(dst); }
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException { return delegate.read(dsts, offset, length); }
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException { return source.read(dsts, offset, length); }
public long read(final ByteBuffer[] dsts) throws IOException { return source.read(dsts); }
public int read(final ByteBuffer dst) throws IOException { return delegate.read(dst); }
@Override public int read(ByteBuffer dst) throws IOException { int position = dst.position(); int r = channel.read(dst); if (r > 0) { afterReading(dst, position, r); } return r; }
public long read(final ByteBuffer[] dsts) throws IOException { if (isFinished()) { return -1; } return delegate.read(dsts); }
public int read(final ByteBuffer dst) throws IOException { if (isFinished()) { return -1; } return delegate.read(dst); }
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException { if (isFinished()) { return -1; } return delegate.read(dsts, offset, length); }
@Override @Nullable protected DataBuffer read() throws IOException { PooledByteBuffer pooledByteBuffer = this.byteBufferPool.allocate(); boolean release = true; try { ByteBuffer byteBuffer = pooledByteBuffer.getBuffer(); int read = this.channel.read(byteBuffer); if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "Read " + read + (read != -1 ? " bytes" : "")); } if (read > 0) { byteBuffer.flip(); DataBuffer dataBuffer = this.bufferFactory.wrap(byteBuffer); release = false; return new UndertowDataBuffer(dataBuffer, pooledByteBuffer); } else if (read == -1) { onAllDataRead(); } return null; } finally { if (release && pooledByteBuffer.isOpen()) { pooledByteBuffer.close(); } } }
ByteBuffer buffer = pooled.getBuffer(); buffer.clear(); r = channel.read(buffer); buffer.flip(); if (r == 0) {
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException { long cnt; try { final ByteBuffer src = buffer.getResource(); cnt = Buffers.copy(dsts, offset, length, src); if (src.hasRemaining()) { return cnt; } final StreamSourceChannel next = channel = this.next; buffer.free(); if (cnt > 0L && next == firstChannel) { // don't hit the main channel until the user wants to return cnt; } } catch (IllegalStateException ignored) { channel = next; cnt = 0; } final long res = next.read(dsts, offset, length); return res > 0 ? res + cnt : cnt > 0 ? cnt : res; }
@Override @Nullable protected DataBuffer read() throws IOException { PooledByteBuffer pooledByteBuffer = this.byteBufferPool.allocate(); boolean release = true; try { ByteBuffer byteBuffer = pooledByteBuffer.getBuffer(); int read = this.channel.read(byteBuffer); if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "Read " + read + (read != -1 ? " bytes" : "")); } if (read > 0) { byteBuffer.flip(); DataBuffer dataBuffer = this.bufferFactory.wrap(byteBuffer); release = false; return new UndertowDataBuffer(dataBuffer, pooledByteBuffer); } else if (read == -1) { onAllDataRead(); } return null; } finally { if (release && pooledByteBuffer.isOpen()) { pooledByteBuffer.close(); } } }
private void readIntoBufferNonBlocking() throws IOException { if (pooled == null && !anyAreSet(state, FLAG_FINISHED)) { pooled = bufferPool.allocate(); int res = channel.read(pooled.getBuffer()); if (res == 0) { pooled.close(); pooled = null; return; } pooled.getBuffer().flip(); if (res == -1) { state |= FLAG_FINISHED; pooled.close(); pooled = null; } } }