public Pooled<ByteBuffer> getBuffer(boolean firstBuffer) throws IOException { Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); //Reserve room for the transmit data which is 4 bytes buffer.limit(buffer.limit() - 4); buffer.put(firstBuffer ? Protocol.MSG_FLAG_NEW : 0); // flags // header size plus window size int windowPlusHeader = maximumWindow + 8; if (buffer.remaining() > windowPlusHeader) { // never try to write more than the maximum window size buffer.limit(windowPlusHeader); } ok = true; return pooled; } finally { if (! ok) pooled.free(); } }
pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try {
public Pooled<ByteBuffer> getBuffer(boolean firstBuffer) throws IOException { Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); //Reserve room for the transmit data which is 4 bytes buffer.limit(buffer.limit() - 4); buffer.put(firstBuffer ? Protocol.MSG_FLAG_NEW : 0); // flags // header size plus window size int windowPlusHeader = maximumWindow + 8; if (buffer.remaining() > windowPlusHeader) { // never try to write more than the maximum window size buffer.limit(windowPlusHeader); } ok = true; return pooled; } finally { if (! ok) pooled.free(); } }
public Pooled<ByteBuffer> getBuffer(boolean firstBuffer) throws IOException { Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); //Reserve room for the transmit data which is 4 bytes buffer.limit(buffer.limit() - 4); buffer.put(firstBuffer ? Protocol.MSG_FLAG_NEW : 0); // flags // header size plus window size int windowPlusHeader = maximumWindow + 8; if (buffer.remaining() > windowPlusHeader) { // never try to write more than the maximum window size buffer.limit(windowPlusHeader); } ok = true; return pooled; } finally { if (! ok) pooled.free(); } }
pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try {
pooled = allocate(Protocol.MESSAGE_DATA); boolean ok = false; try {