Issue #12023 - Remove deprecated classes/methods. (#12149)

Removed deprecated classes/methods from jetty-client.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2024-08-26 12:42:53 +03:00 committed by GitHub
parent cffda533e3
commit 272895ce02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 31 additions and 570 deletions

View File

@ -13,7 +13,6 @@
package org.eclipse.jetty.client;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.time.Duration;
import java.util.Map;
@ -73,10 +72,4 @@ public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpC
context.put(ClientConnector.CLIENT_CONNECTOR_CONTEXT_KEY, connector);
destination.getOrigin().getTransport().connect(address, context);
}
@Override
public void connect(InetSocketAddress address, Map<String, Object> context)
{
connect((SocketAddress)address, context);
}
}

View File

@ -1,121 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.client;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.client.internal.HttpContentResponse;
/**
* A {@link BufferingResponseListener} that is also a {@link Future}, to allow applications
* to block (indefinitely or for a timeout) until {@link #onComplete(Result)} is called,
* or to {@link #cancel(boolean) abort} the request/response conversation.
* <p>
* Typical usage is:
* <pre>
* Request request = httpClient.newRequest(...)...;
* FutureResponseListener listener = new FutureResponseListener(request);
* request.send(listener); // Asynchronous send
* ContentResponse response = listener.get(5, TimeUnit.SECONDS); // Timed block
* </pre>
*
* @deprecated Use {@link CompletableResponseListener} instead
*/
@Deprecated
public class FutureResponseListener extends BufferingResponseListener implements Future<ContentResponse>
{
private final AtomicBoolean cancelled = new AtomicBoolean();
private final CountDownLatch latch = new CountDownLatch(1);
private final Request request;
private ContentResponse response;
private Throwable failure;
public FutureResponseListener(Request request)
{
this(request, 2 * 1024 * 1024);
}
public FutureResponseListener(Request request, int maxLength)
{
super(maxLength);
this.request = request;
}
public Request getRequest()
{
return request;
}
@Override
public void onComplete(Result result)
{
response = new HttpContentResponse(result.getResponse(), getContent(), getMediaType(), getEncoding());
failure = result.getFailure();
latch.countDown();
}
@Override
public boolean cancel(boolean mayInterruptIfRunning)
{
if (cancelled.compareAndSet(false, true))
{
request.abort(new CancellationException());
return true;
}
return false;
}
@Override
public boolean isCancelled()
{
return cancelled.get();
}
@Override
public boolean isDone()
{
return latch.getCount() == 0 || isCancelled();
}
@Override
public ContentResponse get() throws InterruptedException, ExecutionException
{
latch.await();
return getResult();
}
@Override
public ContentResponse get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
{
boolean expired = !latch.await(timeout, unit);
if (expired)
throw new TimeoutException();
return getResult();
}
private ContentResponse getResult() throws ExecutionException
{
if (isCancelled())
throw (CancellationException)new CancellationException().initCause(failure);
if (failure != null)
throw new ExecutionException(failure);
return response;
}
}

View File

@ -471,13 +471,7 @@ public class HttpClient extends ContainerLifeCycle implements AutoCloseable
port = normalizePort(scheme, port);
Transport transport = request.getTransport();
if (transport == null)
{
// Ask the ClientConnector for backwards compatibility
// until ClientConnector.Configurator is removed.
transport = connector.newTransport();
if (transport == null)
transport = Transport.TCP_IP;
}
transport = Transport.TCP_IP;
return new Origin(scheme, new Origin.Address(host, port), request.getTag(), protocol, transport);
}

View File

@ -13,7 +13,6 @@
package org.eclipse.jetty.client;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Map;
@ -71,24 +70,8 @@ public interface HttpClientTransport extends ClientConnectionFactory
*
* @param address the address to connect to
* @param context the context information to establish the connection
* @deprecated use {@link #connect(SocketAddress, Map)} instead.
*/
@Deprecated
public void connect(InetSocketAddress address, Map<String, Object> context);
/**
* Establishes a physical connection to the given {@code address}.
*
* @param address the address to connect to
* @param context the context information to establish the connection
*/
public default void connect(SocketAddress address, Map<String, Object> context)
{
if (address instanceof InetSocketAddress)
connect((InetSocketAddress)address, context);
else
throw new UnsupportedOperationException("Unsupported SocketAddress " + address);
}
public void connect(SocketAddress address, Map<String, Object> context);
/**
* @return the factory for ConnectionPool instances

View File

@ -15,7 +15,6 @@ package org.eclipse.jetty.client.transport;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -91,19 +90,6 @@ public class HttpClientTransportDynamic extends AbstractConnectorHttpClientTrans
this(new ClientConnector(), HttpClientConnectionFactory.HTTP11);
}
/**
* <p>Creates a dynamic transport that speaks the given protocols, in order of preference
* (first the most preferred).</p>
*
* @param infos the protocols this dynamic transport speaks
* @deprecated use {@link #HttpClientTransportDynamic(ClientConnector, ClientConnectionFactory.Info...)}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public HttpClientTransportDynamic(ClientConnectionFactory.Info... infos)
{
this(findClientConnector(infos), infos);
}
/**
* <p>Creates a dynamic transport with the given {@link ClientConnector} and the given protocols,
* in order of preference (first the most preferred).</p>
@ -121,14 +107,6 @@ public class HttpClientTransportDynamic extends AbstractConnectorHttpClientTrans
);
}
private static ClientConnector findClientConnector(ClientConnectionFactory.Info[] infos)
{
return Arrays.stream(infos)
.flatMap(info -> info.getContainedBeans(ClientConnector.class).stream())
.findFirst()
.orElseGet(ClientConnector::new);
}
@Override
public Origin newOrigin(Request request)
{
@ -216,11 +194,7 @@ public class HttpClientTransportDynamic extends AbstractConnectorHttpClientTrans
Transport transport = request.getTransport();
if (transport == null)
{
// Ask the ClientConnector for backwards compatibility
// until ClientConnector.Configurator is removed.
transport = getClientConnector().newTransport();
if (transport == null)
transport = matchingInfos.get(0).newTransport();
transport = matchingInfos.get(0).newTransport();
request.transport(transport);
}

View File

@ -70,18 +70,6 @@ public class HttpDestination extends ContainerLifeCycle implements Destination,
private boolean stale;
private long activeNanoTime;
/**
* @param client the {@link HttpClient}
* @param origin the {@link Origin}
* @param intrinsicallySecure whether the destination is intrinsically secure
* @deprecated use {@link #HttpDestination(HttpClient, Origin)} instead
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public HttpDestination(HttpClient client, Origin origin, boolean intrinsicallySecure)
{
this(client, origin);
}
/**
* <p>Creates a new HTTP destination.</p>
*

View File

@ -124,12 +124,6 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
connect(address, destination.getClientConnectionFactory(), listenerPromise, listenerPromise, context);
}
@Override
public void connect(InetSocketAddress address, Map<String, Object> context)
{
connect((SocketAddress)address, context);
}
protected void connect(SocketAddress address, ClientConnectionFactory factory, Session.Listener listener, Promise<Session> promise, Map<String, Object> context)
{
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);

View File

@ -13,7 +13,6 @@
package org.eclipse.jetty.http3.client.transport;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.time.Duration;
import java.util.List;
@ -99,12 +98,6 @@ public class HttpClientTransportOverHTTP3 extends AbstractHttpClientTransport im
return new HttpDestination(getHttpClient(), origin);
}
@Override
public void connect(InetSocketAddress address, Map<String, Object> context)
{
connect((SocketAddress)address, context);
}
@Override
public void connect(SocketAddress address, Map<String, Object> context)
{

View File

@ -18,18 +18,14 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketOption;
import java.net.StandardProtocolFamily;
import java.net.StandardSocketOptions;
import java.net.UnixDomainSocketAddress;
import java.nio.channels.DatagramChannel;
import java.nio.channels.NetworkChannel;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import org.eclipse.jetty.util.IO;
@ -79,20 +75,6 @@ public class ClientConnector extends ContainerLifeCycle
public static final String APPLICATION_PROTOCOLS_CONTEXT_KEY = CLIENT_CONNECTOR_CONTEXT_KEY + ".applicationProtocols";
private static final Logger LOG = LoggerFactory.getLogger(ClientConnector.class);
/**
* <p>Creates a ClientConnector configured to connect via Unix-Domain sockets to the given Unix-Domain path</p>
*
* @param path the Unix-Domain path to connect to
* @return a ClientConnector that connects to the given Unix-Domain path
* @deprecated replaced by {@link Transport.TCPUnix}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public static ClientConnector forUnixDomain(Path path)
{
return new ClientConnector(Configurator.forUnixDomain(path));
}
private final Configurator configurator;
private Executor executor;
private Scheduler scheduler;
private ByteBufferPool byteBufferPool;
@ -109,36 +91,6 @@ public class ClientConnector extends ContainerLifeCycle
private int receiveBufferSize = -1;
private int sendBufferSize = -1;
public ClientConnector()
{
this(new Configurator());
}
/**
* @param configurator the {@link Configurator}
* @deprecated replaced by {@link Transport}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public ClientConnector(Configurator configurator)
{
this.configurator = Objects.requireNonNull(configurator);
installBean(configurator);
configurator.addBean(this, false);
}
/**
* @param address the SocketAddress to connect to
* @return whether the connection to the given SocketAddress is intrinsically secure
* @see Configurator#isIntrinsicallySecure(ClientConnector, SocketAddress)
*
* @deprecated replaced by {@link Transport#isIntrinsicallySecure()}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public boolean isIntrinsicallySecure(SocketAddress address)
{
return configurator.isIntrinsicallySecure(this, address);
}
public SelectorManager getSelectorManager()
{
return selectorManager;
@ -149,21 +101,6 @@ public class ClientConnector extends ContainerLifeCycle
return executor;
}
/**
* <p>Returns the default {@link Transport} for this connector.</p>
* <p>This method only exists for backwards compatibility, when
* {@link Configurator} was used, and should be removed when
* {@link Configurator} is removed.</p>
*
* @return the default {@link Transport} for this connector
* @deprecated use {@link Transport} instead
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public Transport newTransport()
{
return configurator.newTransport();
}
public void setExecutor(Executor executor)
{
if (isStarted())
@ -632,125 +569,4 @@ public class ClientConnector extends ContainerLifeCycle
connectFailed(failure, context);
}
}
/**
* <p>Configures a {@link ClientConnector}.</p>
*
* @deprecated replaced by {@link Transport}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public static class Configurator extends ContainerLifeCycle
{
/**
* @return the default {@link Transport} for this configurator
*/
public Transport newTransport()
{
return null;
}
/**
* <p>Returns whether the connection to a given {@link SocketAddress} is intrinsically secure.</p>
* <p>A protocol such as HTTP/1.1 can be transported by TCP; however, TCP is not secure because
* it does not offer any encryption.</p>
* <p>Encryption is provided by using TLS to wrap the HTTP/1.1 bytes, and then transporting the
* TLS bytes over TCP.</p>
* <p>On the other hand, protocols such as QUIC are intrinsically secure, and therefore it is
* not necessary to wrap the HTTP/1.1 bytes with TLS: the HTTP/1.1 bytes are transported over
* QUIC in an intrinsically secure way.</p>
*
* @param clientConnector the ClientConnector
* @param address the SocketAddress to connect to
* @return whether the connection to the given SocketAddress is intrinsically secure
*/
public boolean isIntrinsicallySecure(ClientConnector clientConnector, SocketAddress address)
{
return false;
}
/**
* <p>Creates a new {@link SocketChannel} to connect to a {@link SocketAddress}
* derived from the input socket address.</p>
* <p>The input socket address represents the destination socket address to
* connect to, as it is typically specified by a URI authority, for example
* {@code localhost:8080} if the URI is {@code http://localhost:8080/path}.</p>
* <p>However, the returned socket address may be different as the implementation
* may use a Unix-Domain socket address to physically connect to the virtual
* destination socket address given as input.</p>
* <p>The return type is a pair/record holding the socket channel and the
* socket address, with the socket channel not yet connected.
* The implementation of this methods must not call
* {@link SocketChannel#connect(SocketAddress)}, as this is done later,
* after configuring the socket, by the {@link ClientConnector} implementation.</p>
*
* @param clientConnector the client connector requesting channel with associated address
* @param address the destination socket address, typically specified in a URI
* @param context the context to create the new socket channel
* @return a new {@link SocketChannel} with an associated {@link SocketAddress} to connect to
* @throws IOException if the socket channel or the socket address cannot be created
*/
public ChannelWithAddress newChannelWithAddress(ClientConnector clientConnector, SocketAddress address, Map<String, Object> context) throws IOException
{
return new ChannelWithAddress(SocketChannel.open(), address);
}
public EndPoint newEndPoint(ClientConnector clientConnector, SocketAddress address, SelectableChannel selectable, ManagedSelector selector, SelectionKey selectionKey)
{
return new SocketChannelEndPoint((SocketChannel)selectable, selector, selectionKey, clientConnector.getScheduler());
}
public Connection newConnection(ClientConnector clientConnector, SocketAddress address, EndPoint endPoint, Map<String, Object> context) throws IOException
{
ClientConnectionFactory factory = (ClientConnectionFactory)context.get(CLIENT_CONNECTION_FACTORY_CONTEXT_KEY);
return factory.newConnection(endPoint, context);
}
/**
* <p>A pair/record holding a {@link SelectableChannel} and a {@link SocketAddress} to connect to.</p>
*
* @deprecated replaced by {@link Transport}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public static class ChannelWithAddress
{
private final SelectableChannel channel;
private final SocketAddress address;
public ChannelWithAddress(SelectableChannel channel, SocketAddress address)
{
this.channel = channel;
this.address = address;
}
public SelectableChannel getSelectableChannel()
{
return channel;
}
public SocketAddress getSocketAddress()
{
return address;
}
}
private static Configurator forUnixDomain(Path path)
{
return new Configurator()
{
@Override
public Transport newTransport()
{
return new Transport.TCPUnix(path);
}
@Override
public ChannelWithAddress newChannelWithAddress(ClientConnector clientConnector, SocketAddress address, Map<String, Object> context) throws IOException
{
SocketChannel socketChannel = SocketChannel.open(StandardProtocolFamily.UNIX);
UnixDomainSocketAddress socketAddress = UnixDomainSocketAddress.of(path);
return new ChannelWithAddress(socketChannel, socketAddress);
}
};
}
}
}

View File

@ -1,136 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.quic.client;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.Map;
import java.util.Objects;
import java.util.function.UnaryOperator;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.DatagramChannelEndPoint;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.io.Transport;
import org.eclipse.jetty.quic.common.QuicConfiguration;
import org.eclipse.jetty.util.ssl.SslContextFactory;
/**
* <p>A QUIC specific {@link ClientConnector.Configurator}.</p>
* <p>Since QUIC is based on UDP, this class creates {@link DatagramChannel}s instead of
* {@link SocketChannel}s, and {@link DatagramChannelEndPoint}s instead of
* {@link SocketChannelEndPoint}s.</p>
*
* @see QuicConfiguration
* @deprecated replaced by {@link Transport}
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public class QuicClientConnectorConfigurator extends ClientConnector.Configurator
{
private final QuicConfiguration initQuicConfig = new QuicConfiguration();
private final UnaryOperator<Connection> configurator;
private ClientQuicConfiguration quicConfig;
public QuicClientConnectorConfigurator()
{
this(UnaryOperator.identity());
}
public QuicClientConnectorConfigurator(UnaryOperator<Connection> configurator)
{
this.configurator = Objects.requireNonNull(configurator);
// Initialize to sane defaults for a client.
initQuicConfig.setSessionRecvWindow(16 * 1024 * 1024);
initQuicConfig.setBidirectionalStreamRecvWindow(8 * 1024 * 1024);
initQuicConfig.setDisableActiveMigration(true);
}
public QuicConfiguration getQuicConfiguration()
{
if (!isStarted())
return initQuicConfig;
else
return quicConfig;
}
@Override
protected void doStart() throws Exception
{
ClientConnector clientConnector = getBean(ClientConnector.class);
SslContextFactory.Client sslContextFactory = clientConnector.getSslContextFactory();
quicConfig = new ClientQuicConfiguration(sslContextFactory, initQuicConfig.getPemWorkDirectory());
addBean(quicConfig);
quicConfig.setInputBufferSize(initQuicConfig.getInputBufferSize());
quicConfig.setOutputBufferSize(initQuicConfig.getOutputBufferSize());
quicConfig.setUseInputDirectByteBuffers(initQuicConfig.isUseInputDirectByteBuffers());
quicConfig.setUseOutputDirectByteBuffers(initQuicConfig.isUseOutputDirectByteBuffers());
quicConfig.setProtocols(initQuicConfig.getProtocols());
quicConfig.setDisableActiveMigration(initQuicConfig.isDisableActiveMigration());
quicConfig.setMaxBidirectionalRemoteStreams(initQuicConfig.getMaxBidirectionalRemoteStreams());
quicConfig.setMaxUnidirectionalRemoteStreams(initQuicConfig.getMaxUnidirectionalRemoteStreams());
quicConfig.setSessionRecvWindow(initQuicConfig.getSessionRecvWindow());
quicConfig.setBidirectionalStreamRecvWindow(initQuicConfig.getBidirectionalStreamRecvWindow());
quicConfig.setUnidirectionalStreamRecvWindow(initQuicConfig.getUnidirectionalStreamRecvWindow());
quicConfig.getImplementationConfiguration().putAll(initQuicConfig.getImplementationConfiguration());
super.doStart();
}
@Override
public Transport newTransport()
{
return new QuicTransport(quicConfig);
}
@Override
public boolean isIntrinsicallySecure(ClientConnector clientConnector, SocketAddress address)
{
return true;
}
@Override
public ChannelWithAddress newChannelWithAddress(ClientConnector clientConnector, SocketAddress address, Map<String, Object> context) throws IOException
{
context.put(QuicConfiguration.CONTEXT_KEY, initQuicConfig);
DatagramChannel channel = DatagramChannel.open();
if (clientConnector.getBindAddress() == null)
{
// QUIC must know the local address for connection migration, so we must always bind early.
channel.bind(null);
}
return new ChannelWithAddress(channel, address);
}
@Override
public EndPoint newEndPoint(ClientConnector clientConnector, SocketAddress address, SelectableChannel selectable, ManagedSelector selector, SelectionKey selectionKey)
{
return new DatagramChannelEndPoint((DatagramChannel)selectable, selector, selectionKey, clientConnector.getScheduler());
}
@Override
public Connection newConnection(ClientConnector clientConnector, SocketAddress address, EndPoint endPoint, Map<String, Object> context)
{
return configurator.apply(new ClientQuicConnection(clientConnector, endPoint, context));
}
}

View File

@ -30,6 +30,7 @@ import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.quic.server.QuicServerConnector;
import org.eclipse.jetty.quic.server.ServerQuicConfiguration;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
@ -65,6 +66,7 @@ public class End2EndClientTest
</body>
</html>
""";
private QuicTransport transport;
@BeforeEach
public void setUp() throws Exception
@ -83,9 +85,8 @@ public class End2EndClientTest
HttpConfiguration httpConfiguration = new HttpConfiguration();
HttpConnectionFactory http1 = new HttpConnectionFactory(httpConfiguration);
HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfiguration);
// Use the deprecated APIs for backwards compatibility testing.
connector = new QuicServerConnector(server, sslContextFactory, http1, http2);
connector.getQuicConfiguration().setPemWorkDirectory(workDir.getEmptyPathDir());
ServerQuicConfiguration serverQuicConfiguration = new ServerQuicConfiguration(sslContextFactory, workDir.getEmptyPathDir());
connector = new QuicServerConnector(server, serverQuicConfiguration, http1, http2);
server.addConnector(connector);
server.setHandler(new Handler.Abstract()
@ -100,9 +101,9 @@ public class End2EndClientTest
server.start();
// Use the deprecated APIs for backwards compatibility testing.
ClientConnector clientConnector = new ClientConnector(new QuicClientConnectorConfigurator());
SslContextFactory.Client clientSslContextFactory = new SslContextFactory.Client(true);
transport = new QuicTransport(new ClientQuicConfiguration(clientSslContextFactory, null));
ClientConnector clientConnector = new ClientConnector();
clientConnector.setSslContextFactory(clientSslContextFactory);
ClientConnectionFactory.Info http1Info = HttpClientConnectionFactory.HTTP11;
ClientConnectionFactoryOverHTTP2.HTTP2 http2Info = new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(clientConnector));
@ -123,6 +124,7 @@ public class End2EndClientTest
public void testSimpleHTTP1() throws Exception
{
ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort())
.transport(transport)
.timeout(5, TimeUnit.SECONDS)
.send();
assertThat(response.getStatus(), is(200));
@ -135,6 +137,7 @@ public class End2EndClientTest
{
ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort())
.version(HttpVersion.HTTP_2)
.transport(transport)
.timeout(5, TimeUnit.SECONDS)
.send();
assertThat(response.getStatus(), is(200));
@ -148,6 +151,7 @@ public class End2EndClientTest
for (int i = 0; i < 1000; i++)
{
ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort() + "/" + i)
.transport(transport)
.timeout(5, TimeUnit.SECONDS)
.send();
assertThat(response.getStatus(), is(200));
@ -169,7 +173,9 @@ public class End2EndClientTest
{
try
{
ContentResponse response = client.GET("https://localhost:" + connector.getLocalPort() + path);
ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort() + path)
.transport(transport)
.send();
assertThat(response.getStatus(), is(200));
String contentAsString = response.getContentAsString();
assertThat(contentAsString, is(responseContent));
@ -178,7 +184,7 @@ public class End2EndClientTest
{
throw new RuntimeException(e);
}
});
}, client.getExecutor());
}
CompletableFuture.allOf(futures)
.orTimeout(15, TimeUnit.SECONDS)

View File

@ -30,7 +30,9 @@ import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.Transport;
import org.eclipse.jetty.quic.server.QuicServerConnector;
import org.eclipse.jetty.quic.server.ServerQuicConfiguration;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
@ -67,6 +69,7 @@ public class End2EndClientWithClientCertAuthTest
\t</body>
</html>""";
private SslContextFactory.Server serverSslContextFactory;
private Transport transport;
@BeforeEach
public void setUp() throws Exception
@ -95,9 +98,8 @@ public class End2EndClientWithClientCertAuthTest
httpConfiguration.addCustomizer(new SecureRequestCustomizer());
HttpConnectionFactory http1 = new HttpConnectionFactory(httpConfiguration);
HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfiguration);
// Use the deprecated APIs for backwards compatibility testing.
connector = new QuicServerConnector(server, serverSslContextFactory, http1, http2);
connector.getQuicConfiguration().setPemWorkDirectory(serverWorkPath);
ServerQuicConfiguration serverQuicConfiguration = new ServerQuicConfiguration(serverSslContextFactory, serverWorkPath);
connector = new QuicServerConnector(server, serverQuicConfiguration, http1, http2);
server.addConnector(connector);
server.setHandler(new Handler.Abstract()
@ -112,15 +114,16 @@ public class End2EndClientWithClientCertAuthTest
server.start();
// Use the deprecated APIs for backwards compatibility testing.
QuicClientConnectorConfigurator configurator = new QuicClientConnectorConfigurator();
configurator.getQuicConfiguration().setPemWorkDirectory(clientWorkPath);
ClientConnector clientConnector = new ClientConnector(configurator);
SslContextFactory.Client clientSslContextFactory = new SslContextFactory.Client();
clientSslContextFactory.setCertAlias("mykey");
clientSslContextFactory.setKeyStore(keyStore);
clientSslContextFactory.setKeyStorePassword("storepwd");
clientSslContextFactory.setTrustStore(keyStore);
clientSslContextFactory.setTrustStorePassword("storepwd");
ClientQuicConfiguration clientQuicConfiguration = new ClientQuicConfiguration(clientSslContextFactory, clientWorkPath);
clientQuicConfiguration.start();
transport = new QuicTransport(clientQuicConfiguration);
ClientConnector clientConnector = new ClientConnector();
clientConnector.setSslContextFactory(clientSslContextFactory);
ClientConnectionFactory.Info http1Info = HttpClientConnectionFactory.HTTP11;
ClientConnectionFactoryOverHTTP2.HTTP2 http2Info = new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(clientConnector));
@ -141,6 +144,7 @@ public class End2EndClientWithClientCertAuthTest
{
ContentResponse response = client.newRequest("https://localhost:" + connector.getLocalPort())
.timeout(5, TimeUnit.SECONDS)
.transport(transport)
.send();
assertThat(response.getStatus(), is(200));
String contentAsString = response.getContentAsString();
@ -150,12 +154,13 @@ public class End2EndClientWithClientCertAuthTest
@Test
public void testServerRejectsClientInvalidCert() throws Exception
{
// remove the trust store config from the server
// Remove the trust store config from the server.
server.stop();
serverSslContextFactory.setTrustStore(null);
server.start();
assertThrows(TimeoutException.class, () -> client.newRequest("https://localhost:" + connector.getLocalPort())
.transport(transport)
.timeout(1, TimeUnit.SECONDS)
.send());
}

View File

@ -37,7 +37,6 @@ import org.eclipse.jetty.server.AbstractNetworkConnector;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
/**
@ -57,38 +56,11 @@ public class QuicServerConnector extends AbstractNetworkConnector
private volatile DatagramChannel datagramChannel;
private volatile int localPort = -1;
/**
* @param server the {@link Server}
* @param sslContextFactory the {@link SslContextFactory.Server}
* @param factories the {@link ConnectionFactory}s of the protocols transported by QUIC
* @deprecated use {@link #QuicServerConnector(Server, ServerQuicConfiguration, ConnectionFactory...)} instead
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public QuicServerConnector(Server server, SslContextFactory.Server sslContextFactory, ConnectionFactory... factories)
{
this(server, new ServerQuicConfiguration(sslContextFactory, null), factories);
}
public QuicServerConnector(Server server, ServerQuicConfiguration quicConfiguration, ConnectionFactory... factories)
{
this(server, null, null, null, quicConfiguration, factories);
}
/**
* @param server the {@link Server}
* @param executor the {@link Executor}
* @param scheduler the {@link Scheduler}
* @param bufferPool the {@link ByteBufferPool}
* @param sslContextFactory the {@link SslContextFactory.Server}
* @param factories the {@link ConnectionFactory}s of the protocols transported by QUIC
* @deprecated use {@link #QuicServerConnector(Server, Executor, Scheduler, ByteBufferPool, ServerQuicConfiguration, ConnectionFactory...)} instead
*/
@Deprecated(since = "12.0.7", forRemoval = true)
public QuicServerConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, SslContextFactory.Server sslContextFactory, ConnectionFactory... factories)
{
this(server, executor, scheduler, bufferPool, new ServerQuicConfiguration(sslContextFactory, null), factories);
}
public QuicServerConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, ServerQuicConfiguration quicConfiguration, ConnectionFactory... factories)
{
super(server, executor, scheduler, bufferPool, 0, factories);

View File

@ -109,12 +109,12 @@ public class UnixDomainTest
}
});
// Use the deprecated APIs for backwards compatibility testing.
ClientConnector clientConnector = ClientConnector.forUnixDomain(unixDomainPath);
ClientConnector clientConnector = new ClientConnector();
try (HttpClient httpClient = new HttpClient(new HttpClientTransportDynamic(clientConnector)))
{
httpClient.start();
ContentResponse response = httpClient.newRequest(uri)
.transport(new Transport.TCPUnix(unixDomainPath))
.timeout(5, TimeUnit.SECONDS)
.send();