Do not forget to put the buffer back in the pool queue

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-09 23:18:14 +02:00
parent 526108b896
commit fd027ecfd7

View File

@ -280,7 +280,8 @@ public class PlayerSocketConnection extends PlayerConnection {
final Cipher cipher = encryptCipher;
// Encrypt data first
ByteBuffer cipherInput = localBuffer.asByteBuffer(0, localBuffer.writerOffset());
ByteBuffer cipherOutput = getPooledBuffer().asByteBuffer(0, BUFFER_SIZE);
BinaryBuffer pooled = getPooledBuffer();
ByteBuffer cipherOutput = pooled.asByteBuffer(0, BUFFER_SIZE);
try {
cipher.update(cipherInput, cipherOutput);
} catch (ShortBufferException e) {
@ -288,6 +289,7 @@ public class PlayerSocketConnection extends PlayerConnection {
}
localBuffer.clear();
localBuffer.write(cipherOutput.flip());
POOLED_BUFFERS.add(new SoftReference<>(pooled));
}
this.waitingBuffers.add(localBuffer);