Make all methods of SslBufferPool public so a subclass can be placed in another package. See #336
This commit is contained in:
parent
d2ec45e573
commit
88d60c15c7
@ -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);
|
||||||
@ -96,7 +109,24 @@ public class SslBufferPool {
|
|||||||
return (ByteBuffer) pool[-- index].clear();
|
return (ByteBuffer) pool[-- index].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
@ -670,7 +670,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;
|
||||||
@ -776,7 +776,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);
|
||||||
@ -844,7 +844,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 {
|
||||||
@ -915,7 +915,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) {
|
||||||
@ -928,7 +928,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;
|
||||||
@ -1019,7 +1019,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