From 33feac33e7f39c8553dfbd98315d18c715e2b1c0 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 18 Apr 2024 15:52:03 +1000 Subject: [PATCH] Revert "Revert NON_POOLING change" (#11649) This reverts commit 2bf7d6cecc84ea3ab382b229103c43d65c4a0f4c. --- .../java/org/eclipse/jetty/http/GZIPContentDecoder.java | 2 +- .../java/org/eclipse/jetty/http/MultiPartByteRanges.java | 2 +- .../jetty/http/content/CachingHttpContentFactory.java | 2 +- .../eclipse/jetty/http3/internal/DataGenerateParseTest.java | 2 +- .../jetty/http3/internal/GoAwayGenerateParseTest.java | 2 +- .../jetty/http3/internal/HeadersGenerateParseTest.java | 2 +- .../jetty/http3/internal/SettingsGenerateParseTest.java | 2 +- .../jetty/http3/qpack/DecoderInstructionParserTest.java | 2 +- .../eclipse/jetty/http3/qpack/InstructionGeneratorTest.java | 2 +- .../java/org/eclipse/jetty/http3/qpack/QpackTestUtil.java | 4 ++-- .../java/org/eclipse/jetty/io/ByteBufferAccumulator.java | 2 +- .../java/org/eclipse/jetty/io/ByteBufferAggregator.java | 2 +- .../java/org/eclipse/jetty/io/ByteBufferOutputStream2.java | 2 +- .../src/main/java/org/eclipse/jetty/io/ByteBufferPool.java | 2 ++ .../src/main/java/org/eclipse/jetty/io/IOResources.java | 4 ++-- .../org/eclipse/jetty/io/content/BufferedContentSink.java | 2 +- .../eclipse/jetty/io/content/InputStreamContentSource.java | 2 +- .../org/eclipse/jetty/io/content/PathContentSource.java | 2 +- .../org/eclipse/jetty/server/handler/ResourceHandler.java | 4 ++-- .../test/java/org/eclipse/jetty/server/MockConnector.java | 2 +- .../jetty/server/handler/ResourceHandlerByteRangesTest.java | 4 ++-- .../java/org/eclipse/jetty/websocket/core/ParserTest.java | 6 +++--- .../jetty/websocket/common/OutgoingMessageCapture.java | 2 +- .../java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java | 4 ++-- .../org/eclipse/jetty/ee10/servlet/DefaultServletTest.java | 4 ++-- .../java/org/eclipse/jetty/ee9/nested/ResourceHandler.java | 4 ++-- .../java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java | 4 ++-- .../jetty/ee9/websocket/common/OutgoingMessageCapture.java | 2 +- 28 files changed, 39 insertions(+), 37 deletions(-) diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java index 45c41eda497..dcd4b733ef0 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java @@ -67,7 +67,7 @@ public class GZIPContentDecoder implements Destroyable _inflaterEntry = inflaterPool.acquire(); _inflater = _inflaterEntry.get(); _bufferSize = bufferSize; - _pool = byteBufferPool != null ? byteBufferPool : new ByteBufferPool.NonPooling(); + _pool = byteBufferPool != null ? byteBufferPool : ByteBufferPool.NON_POOLING; reset(); } diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java index 4bea6585684..e2de9ca80fb 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartByteRanges.java @@ -239,7 +239,7 @@ public class MultiPartByteRanges super(null, null, headers); this.resource = resource; this.byteRange = byteRange; - this.bufferPool = bufferPool == null ? new ByteBufferPool.NonPooling() : bufferPool; + this.bufferPool = bufferPool == null ? ByteBufferPool.NON_POOLING : bufferPool; } @Override diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/content/CachingHttpContentFactory.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/content/CachingHttpContentFactory.java index e3fc478d70a..15a5402e62e 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/content/CachingHttpContentFactory.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/content/CachingHttpContentFactory.java @@ -77,7 +77,7 @@ public class CachingHttpContentFactory implements HttpContent.Factory public CachingHttpContentFactory(HttpContent.Factory authority, ByteBufferPool bufferPool) { _authority = authority; - _bufferPool = bufferPool != null ? bufferPool : new ByteBufferPool.NonPooling(); + _bufferPool = bufferPool != null ? bufferPool : ByteBufferPool.NON_POOLING; } protected ConcurrentMap getCache() diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/DataGenerateParseTest.java b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/DataGenerateParseTest.java index ffdbfa6a6cc..ad00745cdcd 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/DataGenerateParseTest.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/DataGenerateParseTest.java @@ -55,7 +55,7 @@ public class DataGenerateParseTest byteBuffer.get(inputBytes); DataFrame input = new DataFrame(ByteBuffer.wrap(inputBytes), true); - ByteBufferPool.NonPooling bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); new MessageGenerator(bufferPool, null, true).generate(accumulator, 0, input, null); diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/GoAwayGenerateParseTest.java b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/GoAwayGenerateParseTest.java index 129eca7818d..69bd92139d5 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/GoAwayGenerateParseTest.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/GoAwayGenerateParseTest.java @@ -34,7 +34,7 @@ public class GoAwayGenerateParseTest { GoAwayFrame input = GoAwayFrame.CLIENT_GRACEFUL; - ByteBufferPool.NonPooling bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); new ControlGenerator(bufferPool, true).generate(accumulator, 0, input, null); diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/HeadersGenerateParseTest.java b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/HeadersGenerateParseTest.java index d4a886ea47c..e5804ab6f1e 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/HeadersGenerateParseTest.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/HeadersGenerateParseTest.java @@ -49,7 +49,7 @@ public class HeadersGenerateParseTest QpackEncoder encoder = new QpackEncoder(instructions -> {}); encoder.setMaxHeadersSize(4 * 1024); - ByteBufferPool.NonPooling bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); new MessageGenerator(bufferPool, encoder, true).generate(accumulator, 0, input, null); diff --git a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/SettingsGenerateParseTest.java b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/SettingsGenerateParseTest.java index 450c04cea43..cd52d2fcbbb 100644 --- a/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/SettingsGenerateParseTest.java +++ b/jetty-core/jetty-http3/jetty-http3-common/src/test/java/org/eclipse/jetty/http3/internal/SettingsGenerateParseTest.java @@ -46,7 +46,7 @@ public class SettingsGenerateParseTest { SettingsFrame input = new SettingsFrame(settings); - ByteBufferPool.NonPooling bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); new ControlGenerator(bufferPool, true).generate(accumulator, 0, input, null); diff --git a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/DecoderInstructionParserTest.java b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/DecoderInstructionParserTest.java index 922adcf7677..3216ad7162c 100644 --- a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/DecoderInstructionParserTest.java +++ b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/DecoderInstructionParserTest.java @@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DecoderInstructionParserTest { - private final ByteBufferPool bufferPool = new ByteBufferPool.NonPooling(); + private final ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; private DecoderInstructionParser _instructionParser; private DecoderParserDebugHandler _handler; diff --git a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/InstructionGeneratorTest.java b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/InstructionGeneratorTest.java index df268799ff2..12bb7d74c19 100644 --- a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/InstructionGeneratorTest.java +++ b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/InstructionGeneratorTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.is; public class InstructionGeneratorTest { - private final ByteBufferPool _bufferPool = new ByteBufferPool.NonPooling(); + private final ByteBufferPool _bufferPool = ByteBufferPool.NON_POOLING; private String toHexString(Instruction instruction) { diff --git a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/QpackTestUtil.java b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/QpackTestUtil.java index 5eb580511f3..827d73d1262 100644 --- a/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/QpackTestUtil.java +++ b/jetty-core/jetty-http3/jetty-http3-qpack/src/test/java/org/eclipse/jetty/http3/qpack/QpackTestUtil.java @@ -33,7 +33,7 @@ public class QpackTestUtil { public static ByteBuffer toBuffer(Instruction... instructions) { - ByteBufferPool.NonPooling bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); for (Instruction instruction : instructions) { @@ -57,7 +57,7 @@ public class QpackTestUtil public static ByteBuffer toBuffer(List instructions) { - ByteBufferPool bufferPool = new ByteBufferPool.NonPooling(); + ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator(); instructions.forEach(i -> i.encode(bufferPool, accumulator)); assertThat(accumulator.getSize(), is(instructions.size())); diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAccumulator.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAccumulator.java index 2096be6e91b..6df27c6543f 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAccumulator.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAccumulator.java @@ -44,7 +44,7 @@ public class ByteBufferAccumulator implements AutoCloseable public ByteBufferAccumulator(ByteBufferPool bufferPool, boolean direct) { - _bufferPool = (bufferPool == null) ? new ByteBufferPool.NonPooling() : bufferPool; + _bufferPool = (bufferPool == null) ? ByteBufferPool.NON_POOLING : bufferPool; _direct = direct; } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAggregator.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAggregator.java index 1dd074703e2..3f2939c31dc 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAggregator.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferAggregator.java @@ -53,7 +53,7 @@ public class ByteBufferAggregator throw new IllegalArgumentException("startSize must be > 0, was: " + startSize); if (startSize > maxSize) throw new IllegalArgumentException("maxSize (" + maxSize + ") must be >= startSize (" + startSize + ")"); - _bufferPool = (bufferPool == null) ? new ByteBufferPool.NonPooling() : bufferPool; + _bufferPool = (bufferPool == null) ? ByteBufferPool.NON_POOLING : bufferPool; _direct = direct; _maxSize = maxSize; _currentSize = startSize; diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream2.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream2.java index 9848439c767..6ac69d9dac3 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream2.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream2.java @@ -36,7 +36,7 @@ public class ByteBufferOutputStream2 extends OutputStream public ByteBufferOutputStream2(ByteBufferPool bufferPool, boolean direct) { - _accumulator = new ByteBufferAccumulator(bufferPool == null ? new ByteBufferPool.NonPooling() : bufferPool, direct); + _accumulator = new ByteBufferAccumulator(bufferPool == null ? ByteBufferPool.NON_POOLING : bufferPool, direct); } /** diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferPool.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferPool.java index f9d6965c2bc..292fc7f7d0c 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferPool.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferPool.java @@ -45,6 +45,8 @@ import org.eclipse.jetty.util.BufferUtil; */ public interface ByteBufferPool { + ByteBufferPool NON_POOLING = new NonPooling(); + /** *

Acquires a {@link RetainableByteBuffer} from this pool.

* diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/IOResources.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/IOResources.java index a5986a7b8df..42fdcda26ee 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/IOResources.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/IOResources.java @@ -62,7 +62,7 @@ public class IOResources throw new IllegalArgumentException("Resource length exceeds 2 GiB: " + resource); int length = (int)longLength; - bufferPool = bufferPool == null ? new ByteBufferPool.NonPooling() : bufferPool; + bufferPool = bufferPool == null ? ByteBufferPool.NON_POOLING : bufferPool; // Optimize for PathResource. Path path = resource.getPath(); @@ -371,7 +371,7 @@ public class IOResources if (first > -1) channel.position(first); this.sink = sink; - this.pool = pool == null ? new ByteBufferPool.NonPooling() : pool; + this.pool = pool == null ? ByteBufferPool.NON_POOLING : pool; this.bufferSize = bufferSize <= 0 ? 4096 : bufferSize; this.direct = direct; this.remainingLength = length; diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/BufferedContentSink.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/BufferedContentSink.java index acb85e2ddb6..26a0d972395 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/BufferedContentSink.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/BufferedContentSink.java @@ -64,7 +64,7 @@ public class BufferedContentSink implements Content.Sink if (maxBufferSize < maxAggregationSize) throw new IllegalArgumentException("maxBufferSize (" + maxBufferSize + ") must be >= maxAggregationSize (" + maxAggregationSize + ")"); _delegate = delegate; - _bufferPool = (bufferPool == null) ? new ByteBufferPool.NonPooling() : bufferPool; + _bufferPool = (bufferPool == null) ? ByteBufferPool.NON_POOLING : bufferPool; _direct = direct; _maxBufferSize = maxBufferSize; _maxAggregationSize = maxAggregationSize; diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java index 674d3ecf72e..eebe3436586 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/InputStreamContentSource.java @@ -54,7 +54,7 @@ public class InputStreamContentSource implements Content.Source public InputStreamContentSource(InputStream inputStream, ByteBufferPool bufferPool) { this.inputStream = Objects.requireNonNull(inputStream); - this.bufferPool = bufferPool != null ? bufferPool : new ByteBufferPool.NonPooling(); + this.bufferPool = bufferPool != null ? bufferPool : ByteBufferPool.NON_POOLING; } public int getBufferSize() diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java index 2b0f3bf41f4..46eeda7781b 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/PathContentSource.java @@ -63,7 +63,7 @@ public class PathContentSource implements Content.Source throw new AccessDeniedException(path.toString()); this.path = path; this.length = Files.size(path); - this.byteBufferPool = byteBufferPool != null ? byteBufferPool : new ByteBufferPool.NonPooling(); + this.byteBufferPool = byteBufferPool != null ? byteBufferPool : ByteBufferPool.NON_POOLING; } catch (IOException x) { diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 5c94732dd4b..80623e346c3 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -112,10 +112,10 @@ public class ResourceHandler extends Handler.Wrapper private ByteBufferPool getByteBufferPool(Context context) { if (context == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; Server server = getServer(); if (server == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; return server.getByteBufferPool(); } diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockConnector.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockConnector.java index 885009402c1..c2d827ca96e 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockConnector.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/MockConnector.java @@ -21,7 +21,7 @@ public class MockConnector extends AbstractConnector { public MockConnector(Server server) { - super(server, server.getThreadPool(), server.getScheduler(), new ByteBufferPool.NonPooling(), 0); + super(server, server.getThreadPool(), server.getScheduler(), ByteBufferPool.NON_POOLING, 0); } @Override diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerByteRangesTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerByteRangesTest.java index 7dc7308d08e..4c11c0a4fa0 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerByteRangesTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerByteRangesTest.java @@ -174,7 +174,7 @@ public class ResourceHandlerByteRangesTest { return path -> new ResourceHttpContent(memResource, "text/plain") { - final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), new ByteBufferPool.NonPooling(), false).getByteBuffer(); + final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), ByteBufferPool.NON_POOLING, false).getByteBuffer(); @Override public ByteBuffer getByteBuffer() @@ -215,7 +215,7 @@ public class ResourceHandlerByteRangesTest { return path -> new ResourceHttpContent(memResource, "text/plain") { - final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), new ByteBufferPool.NonPooling(), false).getByteBuffer(); + final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), ByteBufferPool.NON_POOLING, false).getByteBuffer(); @Override public ByteBuffer getByteBuffer() diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java index 8289f448739..db29af20e40 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java @@ -249,7 +249,7 @@ public class ParserTest expected.put(toBuffer(Integer.MAX_VALUE)); expected.flip(); - Parser parser = new Parser(new ByteBufferPool.NonPooling()); + Parser parser = new Parser(ByteBufferPool.NON_POOLING); assertNull(parser.parse(expected)); assertThat(parser.getPayloadLength(), equalTo(Integer.MAX_VALUE)); } @@ -265,7 +265,7 @@ public class ParserTest expected.put(toBuffer(Integer.MAX_VALUE + 1L)); expected.flip(); - Parser parser = new Parser(new ByteBufferPool.NonPooling()); + Parser parser = new Parser(ByteBufferPool.NON_POOLING); assertThrows(MessageTooLargeException.class, () -> parser.parse(expected)); } @@ -280,7 +280,7 @@ public class ParserTest expected.put(new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); expected.flip(); - Parser parser = new Parser(new ByteBufferPool.NonPooling()); + Parser parser = new Parser(ByteBufferPool.NON_POOLING); assertThrows(MessageTooLargeException.class, () -> parser.parse(expected)); } diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java index c8970e284a1..206eb603937 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java @@ -42,7 +42,7 @@ public class OutgoingMessageCapture extends CoreSession.Empty implements CoreSes public BlockingQueue binaryMessages = new LinkedBlockingDeque<>(); public BlockingQueue events = new LinkedBlockingDeque<>(); - private final ByteBufferPool bufferPool = new ByteBufferPool.NonPooling(); + private final ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; private final MethodHandle wholeTextHandle; private final MethodHandle wholeBinaryHandle; private MessageSink messageSink; diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java index f025968c5af..2c350c2f477 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java @@ -320,10 +320,10 @@ public class DefaultServlet extends HttpServlet private static ByteBufferPool getByteBufferPool(ContextHandler contextHandler) { if (contextHandler == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; Server server = contextHandler.getServer(); if (server == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; return server.getByteBufferPool(); } diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java index b3f0cbc52f2..554bce24f1d 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java @@ -3516,7 +3516,7 @@ public class DefaultServletTest context.addServlet(new ServletHolder(defaultServlet), "/"); defaultServlet.getResourceService().setHttpContentFactory(path -> new ResourceHttpContent(memResource, "text/plain") { - final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), new ByteBufferPool.NonPooling(), false).getByteBuffer(); + final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), ByteBufferPool.NON_POOLING, false).getByteBuffer(); @Override public ByteBuffer getByteBuffer() @@ -3570,7 +3570,7 @@ public class DefaultServletTest context.addServlet(new ServletHolder(defaultServlet), "/"); defaultServlet.getResourceService().setHttpContentFactory(path -> new ResourceHttpContent(memResource, "text/plain") { - final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), new ByteBufferPool.NonPooling(), false).getByteBuffer(); + final ByteBuffer buffer = IOResources.toRetainableByteBuffer(getResource(), ByteBufferPool.NON_POOLING, false).getByteBuffer(); @Override public ByteBuffer getByteBuffer() diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java index 85785f92b9d..3e72885f704 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ResourceHandler.java @@ -114,10 +114,10 @@ public class ResourceHandler extends HandlerWrapper implements WelcomeFactory private static ByteBufferPool getByteBufferPool(ContextHandler contextHandler) { if (contextHandler == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; Server server = contextHandler.getServer(); if (server == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; return server.getByteBufferPool(); } diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java index 9f7b734646a..b466d752ca5 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java @@ -318,10 +318,10 @@ public class DefaultServlet extends HttpServlet implements WelcomeFactory private static ByteBufferPool getByteBufferPool(ContextHandler contextHandler) { if (contextHandler == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; Server server = contextHandler.getServer(); if (server == null) - return new ByteBufferPool.NonPooling(); + return ByteBufferPool.NON_POOLING; return server.getByteBufferPool(); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-common/src/test/java/org/eclipse/jetty/ee9/websocket/common/OutgoingMessageCapture.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-common/src/test/java/org/eclipse/jetty/ee9/websocket/common/OutgoingMessageCapture.java index 86689457b19..be891e1cb72 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-common/src/test/java/org/eclipse/jetty/ee9/websocket/common/OutgoingMessageCapture.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-common/src/test/java/org/eclipse/jetty/ee9/websocket/common/OutgoingMessageCapture.java @@ -41,7 +41,7 @@ public class OutgoingMessageCapture extends CoreSession.Empty implements CoreSes public BlockingQueue binaryMessages = new LinkedBlockingDeque<>(); public BlockingQueue events = new LinkedBlockingDeque<>(); - private final ByteBufferPool bufferPool = new ByteBufferPool.NonPooling(); + private final ByteBufferPool bufferPool = ByteBufferPool.NON_POOLING; private final MethodHandle wholeTextHandle; private final MethodHandle wholeBinaryHandle; private MessageSink messageSink;