Make all methods of SslBufferPool public so a subclass can be placed in another package. See #336
This commit is contained in:
parent
1226cdacfb
commit
7007e2fbaf
@ -89,6 +89,19 @@ public class SslBufferPool {
|
|||||||
return index * MAX_PACKET_SIZE;
|
return index * MAX_PACKET_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquire a new {@link ByteBuffer} out of the {@link SslBufferPool}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ByteBuffer acquireBuffer() {
|
||||||
|
return acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will get removed. Please use {@link #acquireBuffer()}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
synchronized ByteBuffer acquire() {
|
synchronized ByteBuffer acquire() {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return ByteBuffer.allocate(MAX_PACKET_SIZE);
|
return ByteBuffer.allocate(MAX_PACKET_SIZE);
|
||||||
@ -97,6 +110,23 @@ public class SslBufferPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release a previous acquired {@link ByteBuffer}
|
||||||
|
*
|
||||||
|
* @param buffer
|
||||||
|
*/
|
||||||
|
public void releaseBuffer(ByteBuffer buffer) {
|
||||||
|
release(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will get removed. Please use {@link #releaseBuffer(ByteBuffer)}
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
synchronized void release(ByteBuffer buffer) {
|
synchronized void release(ByteBuffer buffer) {
|
||||||
if (index < maxBufferCount) {
|
if (index < maxBufferCount) {
|
||||||
pool[index ++] = buffer;
|
pool[index ++] = buffer;
|
||||||
|
@ -660,7 +660,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
|
|
||||||
ChannelFuture future = null;
|
ChannelFuture future = null;
|
||||||
ChannelBuffer msg;
|
ChannelBuffer msg;
|
||||||
ByteBuffer outNetBuf = bufferPool.acquire();
|
ByteBuffer outNetBuf = bufferPool.acquireBuffer();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
boolean offered = false;
|
boolean offered = false;
|
||||||
boolean needsUnwrap = false;
|
boolean needsUnwrap = false;
|
||||||
@ -761,7 +761,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
setHandshakeFailure(channel, e);
|
setHandshakeFailure(channel, e);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
bufferPool.release(outNetBuf);
|
bufferPool.releaseBuffer(outNetBuf);
|
||||||
|
|
||||||
if (offered) {
|
if (offered) {
|
||||||
flushPendingEncryptedWrites(context);
|
flushPendingEncryptedWrites(context);
|
||||||
@ -829,7 +829,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
|
|
||||||
private ChannelFuture wrapNonAppData(ChannelHandlerContext ctx, Channel channel) throws SSLException {
|
private ChannelFuture wrapNonAppData(ChannelHandlerContext ctx, Channel channel) throws SSLException {
|
||||||
ChannelFuture future = null;
|
ChannelFuture future = null;
|
||||||
ByteBuffer outNetBuf = bufferPool.acquire();
|
ByteBuffer outNetBuf = bufferPool.acquireBuffer();
|
||||||
|
|
||||||
SSLEngineResult result;
|
SSLEngineResult result;
|
||||||
try {
|
try {
|
||||||
@ -905,7 +905,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
setHandshakeFailure(channel, e);
|
setHandshakeFailure(channel, e);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
bufferPool.release(outNetBuf);
|
bufferPool.releaseBuffer(outNetBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (future == null) {
|
if (future == null) {
|
||||||
@ -918,7 +918,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
private ChannelBuffer unwrap(
|
private ChannelBuffer unwrap(
|
||||||
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, int offset, int length) throws SSLException {
|
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, int offset, int length) throws SSLException {
|
||||||
ByteBuffer inNetBuf = buffer.toByteBuffer(offset, length);
|
ByteBuffer inNetBuf = buffer.toByteBuffer(offset, length);
|
||||||
ByteBuffer outAppBuf = bufferPool.acquire();
|
ByteBuffer outAppBuf = bufferPool.acquireBuffer();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean needsWrap = false;
|
boolean needsWrap = false;
|
||||||
@ -1008,7 +1008,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
setHandshakeFailure(channel, e);
|
setHandshakeFailure(channel, e);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
bufferPool.release(outAppBuf);
|
bufferPool.releaseBuffer(outAppBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user