File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
core/src/main/java/io/undertow/server Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ public PooledByteBuffer allocate() {
139139 buffer = queue .poll ();
140140 if (buffer != null ) {
141141 currentQueueLengthUpdater .decrementAndGet (this );
142+ //buffer.clear();
142143 }
143144 }
144145 if (buffer == null ) {
@@ -259,20 +260,23 @@ private static class DefaultPooledBuffer implements PooledByteBuffer {
259260
260261 @ Override
261262 public ByteBuffer getBuffer () {
262- if (referenceCount == 0 ) {
263+ final ByteBuffer tmp = this .buffer ;
264+ //UNDERTOW-2072
265+ if (referenceCount == 0 || tmp == null ) {
263266 throw UndertowMessages .MESSAGES .bufferAlreadyFreed ();
264267 }
265- return buffer ;
268+ return tmp ;
266269 }
267270
268271 @ Override
269272 public void close () {
270- if (referenceCountUpdater .compareAndSet (this , 1 , 0 )) {
271- if (leakDetector != null ) {
273+ final ByteBuffer tmp = this .buffer ;
274+ if (referenceCountUpdater .compareAndSet (this , 1 , 0 )) {
275+ this .buffer = null ;
276+ if (leakDetector != null ) {
272277 leakDetector .closed = true ;
273278 }
274- pool .freeInternal (buffer );
275- this .buffer = null ;
279+ pool .freeInternal (tmp );
276280 }
277281 }
278282
You can’t perform that action at this time.
0 commit comments