Skip to content

Commit

Permalink
Rename RetainableByteBufferPool to ByteBufferPool
Browse files Browse the repository at this point in the history
With issue jetty#9166, ByteBufferPool was removed and replaced by
RetainableByteBufferPool. Since ByteBufferPool was used by
AbstractConnector, this change broke backwards compatibility with
third-party connectors such as junixsocket-jetty.

Since there's no longer any other ByteBufferPool, rename the
RetainableByteBufferPool interface, and thereby not only reinstate
compatibility with existing third-party libraries but also save a few
keystrokes.

jetty#9284

Signed-off-by: Christian Kohlschütter <[email protected]>
  • Loading branch information
kohlschuetter committed Feb 3, 2023
1 parent 55a27fc commit 0a0fd8d
Show file tree
Hide file tree
Showing 236 changed files with 857 additions and 826 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public void writeLine(String line, Callback callback)

// Wrap the "telnet" ClientConnectionFactory with the SslClientConnectionFactory.
connectionFactory = new SslClientConnectionFactory(clientConnector.getSslContextFactory(),
clientConnector.getRetainableByteBufferPool(), clientConnector.getExecutor(), connectionFactory);
clientConnector.getByteBufferPool(), clientConnector.getExecutor(), connectionFactory);

// We will obtain a SslConnection now.
CompletableFuture<SslConnection> connectionPromise = new Promise.Completable<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void doStart() throws Exception
{
HttpClient httpClient = getHttpClient();
connector.setBindAddress(httpClient.getBindAddress());
connector.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool());
connector.setByteBufferPool(httpClient.getByteBufferPool());
connector.setConnectBlocking(httpClient.isConnectBlocking());
connector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout()));
connector.setExecutor(httpClient.getExecutor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

package org.eclipse.jetty.client;

import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;

/**
* {@link ContentDecoder} for the "gzip" encoding.
Expand All @@ -33,9 +33,9 @@ public GZIPContentDecoder(int bufferSize)
this(null, bufferSize);
}

public GZIPContentDecoder(RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
{
super(retainableByteBufferPool, bufferSize);
super(byteBufferPool, bufferSize);
}

@Override
Expand All @@ -50,7 +50,7 @@ protected boolean decodedChunk(RetainableByteBuffer chunk)
*/
public static class Factory extends ContentDecoder.Factory
{
private final RetainableByteBufferPool retainableByteBufferPool;
private final ByteBufferPool byteBufferPool;
private final int bufferSize;

public Factory()
Expand All @@ -63,22 +63,22 @@ public Factory(int bufferSize)
this(null, bufferSize);
}

public Factory(RetainableByteBufferPool retainableByteBufferPool)
public Factory(ByteBufferPool byteBufferPool)
{
this(retainableByteBufferPool, DEFAULT_BUFFER_SIZE);
this(byteBufferPool, DEFAULT_BUFFER_SIZE);
}

public Factory(RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public Factory(ByteBufferPool byteBufferPool, int bufferSize)
{
super("gzip");
this.retainableByteBufferPool = retainableByteBufferPool;
this.byteBufferPool = byteBufferPool;
this.bufferSize = bufferSize;
}

@Override
public ContentDecoder newContentDecoder()
{
return new GZIPContentDecoder(retainableByteBufferPool, bufferSize);
return new GZIPContentDecoder(byteBufferPool, bufferSize);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.Jetty;
Expand Down Expand Up @@ -199,9 +199,9 @@ protected void doStart() throws Exception
int maxBucketSize = executor instanceof ThreadPool.SizedThreadPool
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2
: ProcessorUtils.availableProcessors() * 2;
RetainableByteBufferPool retainableByteBufferPool = getRetainableByteBufferPool();
if (retainableByteBufferPool == null)
setRetainableByteBufferPool(new ArrayRetainableByteBufferPool(0, 2048, 65536, maxBucketSize));
ByteBufferPool byteBufferPool = getByteBufferPool();
if (byteBufferPool == null)
setByteBufferPool(new ArrayRetainableByteBufferPool(0, 2048, 65536, maxBucketSize));
Scheduler scheduler = getScheduler();
if (scheduler == null)
{
Expand All @@ -220,7 +220,7 @@ protected void doStart() throws Exception
handlers.put(new ProxyAuthenticationProtocolHandler(this));
handlers.put(new UpgradeProtocolHandler());

decoderFactories.put(new GZIPContentDecoder.Factory(retainableByteBufferPool));
decoderFactories.put(new GZIPContentDecoder.Factory(byteBufferPool));

cookieManager = newCookieManager();
cookieStore = cookieManager.getCookieStore();
Expand Down Expand Up @@ -646,19 +646,19 @@ public ProtocolHandler findProtocolHandler(Request request, Response response)
}

/**
* @return the {@link RetainableByteBufferPool} of this HttpClient
* @return the {@link ByteBufferPool} of this HttpClient
*/
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return connector.getRetainableByteBufferPool();
return connector.getByteBufferPool();
}

/**
* @param retainableByteBufferPool the {@link RetainableByteBufferPool} of this HttpClient
* @param byteBufferPool the {@link ByteBufferPool} of this HttpClient
*/
public void setRetainableByteBufferPool(RetainableByteBufferPool retainableByteBufferPool)
public void setByteBufferPool(ByteBufferPool byteBufferPool)
{
connector.setRetainableByteBufferPool(retainableByteBufferPool);
connector.setByteBufferPool(byteBufferPool);
}

/**
Expand Down Expand Up @@ -1152,6 +1152,6 @@ public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.C
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory);
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import java.io.InputStream;

import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.InputStreamContentSource;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ public InputStreamRequestContent(String contentType, InputStream stream)
this(contentType, stream, null);
}

public InputStreamRequestContent(String contentType, InputStream stream, RetainableByteBufferPool bufferPool)
public InputStreamRequestContent(String contentType, InputStream stream, ByteBufferPool bufferPool)
{
super(stream, bufferPool);
this.contentType = contentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import java.io.IOException;
import java.nio.file.Path;

import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.PathContentSource;

/**
* <p>A {@link Request.Content} for files using JDK 7's {@code java.nio.file} APIs.</p>
* <p>It is possible to specify a buffer size used to read content from the stream,
* by default 4096 bytes, whether the buffer should be direct or not, and a
* {@link RetainableByteBufferPool} from which {@code ByteBuffer}s will be acquired
* {@link ByteBufferPool} from which {@code ByteBuffer}s will be acquired
* to read from the {@code Path}.</p>
*/
public class PathRequestContent extends PathContentSource implements Request.Content
Expand Down Expand Up @@ -51,7 +51,7 @@ public PathRequestContent(String contentType, Path filePath, int bufferSize) thr
setBufferSize(bufferSize);
}

public PathRequestContent(String contentType, Path filePath, RetainableByteBufferPool bufferPool) throws IOException
public PathRequestContent(String contentType, Path filePath, ByteBufferPool bufferPool) throws IOException
{
super(filePath, bufferPool);
this.contentType = contentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Promise;
import org.slf4j.Logger;
Expand All @@ -45,7 +45,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res

private final LongAdder inMessages = new LongAdder();
private final HttpParser parser;
private final RetainableByteBufferPool retainableByteBufferPool;
private final ByteBufferPool byteBufferPool;
private RetainableByteBuffer networkBuffer;
private boolean shutdown;
private boolean complete;
Expand All @@ -66,7 +66,7 @@ public HttpReceiverOverHTTP(HttpChannelOverHTTP channel)
parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize());
parser.setHeaderCacheCaseSensitive(httpTransport.isHeaderCacheCaseSensitive());
}
retainableByteBufferPool = httpClient.getRetainableByteBufferPool();
byteBufferPool = httpClient.getByteBufferPool();
}

void receive()
Expand Down Expand Up @@ -197,7 +197,7 @@ private RetainableByteBuffer newNetworkBuffer()
{
HttpClient client = getHttpDestination().getHttpClient();
boolean direct = client.isUseInputDirectByteBuffers();
return retainableByteBufferPool.acquire(client.getResponseBufferSize(), direct);
return byteBufferPool.acquire(client.getResponseBufferSize(), direct);
}

private void releaseNetworkBuffer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback;
Expand Down Expand Up @@ -158,7 +158,7 @@ private HeadersCallback()
protected Action process() throws Exception
{
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool();
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true)
{
Expand Down Expand Up @@ -289,7 +289,7 @@ public ContentCallback()
protected Action process() throws Exception
{
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool();
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Callback;
Expand Down Expand Up @@ -242,7 +242,7 @@ protected void service(Request request, org.eclipse.jetty.server.Response respon
}
});

RetainableByteBufferPool pool = client.getRetainableByteBufferPool();
ByteBufferPool pool = client.getByteBufferPool();
assumeTrue(pool instanceof ArrayRetainableByteBufferPool);
ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)pool;

Expand Down
Loading

0 comments on commit 0a0fd8d

Please sign in to comment.