NioSslEngine implements NioFilter { public ByteBuffer ensureUnwrappedCapacity(int amount) { peerAppData = bufferPool.expandReadBufferIfNeeded(TRACKED_RECEIVER, peerAppData, amount); return peerAppData; } NioSslEngine(SSLEngine engine, BufferPool bufferPool); boolean handshake(SocketChannel socketChannel, int timeout,
      ByteBuffer peerNetData); @Override synchronized ByteBuffer wrap(ByteBuffer appData); @Override synchronized ByteBuffer unwrap(ByteBuffer wrappedBuffer); @Override ByteBuffer ensureWrappedCapacity(int amount, ByteBuffer wrappedBuffer,
      BufferType bufferType); @Override ByteBuffer readAtLeast(SocketChannel channel, int bytes,
      ByteBuffer wrappedBuffer); @Override ByteBuffer getUnwrappedBuffer(ByteBuffer wrappedBuffer); ByteBuffer ensureUnwrappedCapacity(int amount); @Override void doneReadingDirectAck(ByteBuffer unwrappedBuffer); @Override synchronized void close(SocketChannel socketChannel);  }
@Test public void ensureUnwrappedCapacity() { ByteBuffer wrappedBuffer = ByteBuffer.allocate(netBufferSize); int requestedCapacity = nioSslEngine.getUnwrappedBuffer(wrappedBuffer).capacity() * 2; ByteBuffer unwrappedBuffer = nioSslEngine.ensureUnwrappedCapacity(requestedCapacity); assertThat(unwrappedBuffer.capacity()).isGreaterThanOrEqualTo(requestedCapacity); }