Revert "Revert NON_POOLING change" (#11649)

This reverts commit 2bf7d6cecc.
This commit is contained in:
Greg Wilkins 2024-04-18 15:52:03 +10:00 committed by GitHub
parent 940c7440b4
commit 33feac33e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 39 additions and 37 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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<String, CachingHttpContent> getCache()

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -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<Instruction> 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()));

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
/**

View File

@ -45,6 +45,8 @@ import org.eclipse.jetty.util.BufferUtil;
*/
public interface ByteBufferPool
{
ByteBufferPool NON_POOLING = new NonPooling();
/**
* <p>Acquires a {@link RetainableByteBuffer} from this pool.</p>
*

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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)
{

View File

@ -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();
}

View File

@ -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

View File

@ -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()

View File

@ -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));
}

View File

@ -42,7 +42,7 @@ public class OutgoingMessageCapture extends CoreSession.Empty implements CoreSes
public BlockingQueue<ByteBuffer> binaryMessages = new LinkedBlockingDeque<>();
public BlockingQueue<String> 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;

View File

@ -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();
}

View File

@ -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()

View File

@ -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();
}

View File

@ -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();
}

View File

@ -41,7 +41,7 @@ public class OutgoingMessageCapture extends CoreSession.Empty implements CoreSes
public BlockingQueue<ByteBuffer> binaryMessages = new LinkedBlockingDeque<>();
public BlockingQueue<String> 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;