@@ -135,6 +135,7 @@ enum ClientAuthMode {
135135 private final long ssl ;
136136 private final long networkBIO ;
137137 private final long aprGeneration ;
138+ private ByteBuffer buf = ByteBuffer .allocateDirect (MAX_ENCRYPTED_PACKET_LENGTH );
138139
139140 private enum Accepted {
140141 NOT ,
@@ -234,6 +235,7 @@ public synchronized void shutdown() {
234235 Library .returnCleanUpLock ();
235236 }
236237 }
238+ ByteBufferUtils .cleanDirectBuffer (buf );
237239 }
238240 }
239241
@@ -260,7 +262,6 @@ private int writePlaintextData(final long ssl, final ByteBuffer src) throws SSLE
260262 return sslWrote ;
261263 }
262264 } else {
263- ByteBuffer buf = ByteBuffer .allocateDirect (len );
264265 try {
265266 final long addr = Buffer .address (buf );
266267
@@ -281,7 +282,6 @@ private int writePlaintextData(final long ssl, final ByteBuffer src) throws SSLE
281282 }
282283 } finally {
283284 buf .clear ();
284- ByteBufferUtils .cleanDirectBuffer (buf );
285285 }
286286 }
287287
@@ -308,7 +308,6 @@ private int writeEncryptedData(final long networkBIO, final ByteBuffer src) thro
308308 return netWrote ;
309309 }
310310 } else {
311- ByteBuffer buf = ByteBuffer .allocateDirect (len );
312311 try {
313312 final long addr = Buffer .address (buf );
314313
@@ -326,7 +325,6 @@ private int writeEncryptedData(final long networkBIO, final ByteBuffer src) thro
326325 }
327326 } finally {
328327 buf .clear ();
329- ByteBufferUtils .cleanDirectBuffer (buf );
330328 }
331329 }
332330
@@ -355,7 +353,6 @@ private int readPlaintextData(final long ssl, final ByteBuffer dst) throws SSLEx
355353 final int pos = dst .position ();
356354 final int limit = dst .limit ();
357355 final int len = Math .min (MAX_ENCRYPTED_PACKET_LENGTH , limit - pos );
358- final ByteBuffer buf = ByteBuffer .allocateDirect (len );
359356 try {
360357 final long addr = Buffer .address (buf );
361358
@@ -371,7 +368,6 @@ private int readPlaintextData(final long ssl, final ByteBuffer dst) throws SSLEx
371368 }
372369 } finally {
373370 buf .clear ();
374- ByteBufferUtils .cleanDirectBuffer (buf );
375371 }
376372 }
377373
@@ -396,7 +392,6 @@ private int readEncryptedData(final long networkBIO, final ByteBuffer dst, final
396392 checkLastError ();
397393 }
398394 } else {
399- final ByteBuffer buf = ByteBuffer .allocateDirect (pending );
400395 try {
401396 final long addr = Buffer .address (buf );
402397
@@ -413,7 +408,6 @@ private int readEncryptedData(final long networkBIO, final ByteBuffer dst, final
413408 }
414409 } finally {
415410 buf .clear ();
416- ByteBufferUtils .cleanDirectBuffer (buf );
417411 }
418412 }
419413
0 commit comments