Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXF-8764: Upgrade to Jetty 10 #998

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions distribution/javadoc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
Expand Down Expand Up @@ -490,7 +486,7 @@
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava3</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>
</dependencies>
</profile>
Expand All @@ -107,12 +107,12 @@
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ under the License.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ under the License.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/main/release/samples/jax_rs/sse_cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>

<dependency>
Expand All @@ -81,7 +81,7 @@
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>

<dependency>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
</property>
</activation>
<properties>
<cxf.jetty.version>${cxf.jetty9.version}</cxf.jetty.version>
<cxf.jetty.version>${cxf.jetty10.version}</cxf.jetty.version>
</properties>
<dependencies>
<!-- jetty9 websocket -->
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/${project.name}</webAppSourceDirectory>
<scanIntervalSeconds>1</scanIntervalSeconds>
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/main/release/samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.boot.version>2.7.5</spring.boot.version>
<spring.cloud.eureka.version>3.1.4</spring.cloud.eureka.version>
<cxf.jetty9.version>9.4.49.v20220914</cxf.jetty9.version>
<cxf.jetty10.version>10.0.12</cxf.jetty10.version>
<cxf.netty.version>4.1.85.Final</cxf.netty.version>
<cxf.httpcomponents.client.version>4.5.13</cxf.httpcomponents.client.version>
<cxf.swagger.ui.version>4.15.5</cxf.swagger.ui.version>
Expand Down Expand Up @@ -208,7 +208,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${cxf.jetty9.version}</version>
<version>${cxf.jetty10.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
10 changes: 3 additions & 7 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<cxf.ehcache3.version>3.9.3</cxf.ehcache3.version>
<cxf.el-api.version>3.0.3</cxf.el-api.version>
<cxf.findbugs.version>3.0.2</cxf.findbugs.version>
<cxf.hoverfly.version>0.14.0</cxf.hoverfly.version>
<cxf.geronimo.j2ee.management.version>1.0.1</cxf.geronimo.j2ee.management.version>
<cxf.geronimo.jms.version>1.1.1</cxf.geronimo.jms.version>
<cxf.geronimo.json.version>1.4</cxf.geronimo.json.version>
Expand Down Expand Up @@ -151,8 +152,8 @@
<cxf.jdom.version>1.0</cxf.jdom.version>
<cxf.jettison.version>1.5.2</cxf.jettison.version>
<cxf.jetty.osgi.version>[9.2,10)</cxf.jetty.osgi.version>
<cxf.jetty9.version>9.4.49.v20220914</cxf.jetty9.version>
<cxf.jetty.version>${cxf.jetty9.version}</cxf.jetty.version>
<cxf.jetty10.version>10.0.12</cxf.jetty10.version>
<cxf.jetty.version>${cxf.jetty10.version}</cxf.jetty.version>
<cxf.jexl.version>3.2.1</cxf.jexl.version>
<cxf.joda.time.version>2.10.10</cxf.joda.time.version>
<cxf.johnzon.version>1.2.18</cxf.johnzon.version>
Expand Down Expand Up @@ -1173,11 +1174,6 @@
<artifactId>jetty-security</artifactId>
<version>${cxf.jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
<version>${cxf.jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
Expand Down
16 changes: 4 additions & 12 deletions rt/rs/microprofile-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-tck</artifactId>
Expand Down Expand Up @@ -187,18 +191,6 @@
<version>${cxf.commons-jcs-jcache.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>${cxf.wiremock.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
import org.apache.cxf.jaxrs.model.ProviderInfo;
import org.apache.cxf.jaxrs.provider.jsrjsonb.JsrJsonbProvider;
import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
import org.apache.cxf.microprofile.client.cdi.CDIInterceptorWrapper;
import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
Expand Down Expand Up @@ -78,6 +79,7 @@ public MicroProfileClientFactoryBean(MicroProfileClientConfigurableImpl<RestClie
registeredProviders.add(new ProviderInfo<>(new DefaultResponseExceptionMapper(), getBus(), false));
}
registeredProviders.add(new ProviderInfo<>(new JsrJsonpProvider(), getBus(), false));
registeredProviders.add(new ProviderInfo<>(new JsrJsonbProvider(), getBus(), false));
super.setProviders(registeredProviders);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,79 +18,76 @@
*/
package org.apache.cxf.microprofile.client;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;

import com.github.tomakehurst.wiremock.common.FileSource;
import com.github.tomakehurst.wiremock.extension.Parameters;
import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
import com.github.tomakehurst.wiremock.http.Request;
import com.github.tomakehurst.wiremock.http.Response;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
coheigea marked this conversation as resolved.
Show resolved Hide resolved

import org.apache.cxf.microprofile.client.mock.AsyncClient;
import org.apache.cxf.microprofile.client.mock.NotFoundExceptionMapper;
import org.eclipse.microprofile.rest.client.RestClientBuilder;

import org.junit.Rule;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.notFound;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class AsyncTest {
@SuppressWarnings("unchecked")
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig()
.extensions(SimpleTransformer.class).dynamicPort());

public static class SimpleTransformer extends ResponseTransformer {
private final Queue<String> queue = new ArrayBlockingQueue<>(2);

public SimpleTransformer() {
queue.add("Hello");
queue.add("World");
}

@Override
public Response transform(Request request, Response response, FileSource fileSource, Parameters parameters) {
return Response.Builder
.like(response)
.but().body(queue.poll())
.build();
}
private HttpServer server;
private final Queue<String> queue = new ArrayBlockingQueue<>(2);

public class SimpleHandler implements HttpHandler {
@Override
public boolean applyGlobally() {
return false;
public void handle(HttpExchange exchange) throws IOException {
final String body = queue.poll();
if (body == null) {
exchange.sendResponseHeaders(404, 0);
} else {
exchange.sendResponseHeaders(200, body.length());
try (OutputStream os = exchange.getResponseBody()) {
os.write(body.getBytes());
}
}
}
}

@Override
public String getName() {
return "enqueue-transformer";
}
@Before
public void setUp() throws IOException {
server = HttpServer.create(new InetSocketAddress(0), 2);
server.createContext("/", new SimpleHandler());
server.start();
}


@After
public void tearDown() throws IOException {
server.stop(0);
queue.clear();
}

@Test
public void testAsyncClient() throws Exception {
URI uri = URI.create(wireMockRule.baseUrl());
queue.add("Hello");
queue.add("World");

URI uri = URI.create("http://localhost:" + server.getAddress().getPort());
AsyncClient client = RestClientBuilder.newBuilder()
.baseUri(uri)
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.build(AsyncClient.class);
assertNotNull(client);

wireMockRule.stubFor(get("/").willReturn(ok().withTransformers("enqueue-transformer")));

String combined = client.get().thenCombine(client.get(), (a, b) -> {
return a + " " + b;
}).toCompletableFuture().get(10, TimeUnit.SECONDS);
Expand All @@ -100,14 +97,13 @@ public void testAsyncClient() throws Exception {

@Test
public void testAsyncClientCanMapExceptionResponses() throws Exception {
URI uri = URI.create(wireMockRule.baseUrl());
URI uri = URI.create("http://localhost:" + server.getAddress().getPort());
AsyncClient client = RestClientBuilder.newBuilder()
.baseUri(uri)
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.register(NotFoundExceptionMapper.class)
.build(AsyncClient.class);
wireMockRule.stubFor(get("/").willReturn(notFound()));

CompletionStage<?> cs = client.get().exceptionally(t -> {
Throwable t2 = t.getCause();
Expand Down
4 changes: 0 additions & 4 deletions rt/transports/http-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.configuration.security.CertificateConstraintsType;
import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CopyingOutputStream;
import org.apache.cxf.message.Message;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
import org.apache.cxf.transport.servlet.ServletDestination;
import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
Expand Down Expand Up @@ -372,17 +370,6 @@ public ServerEngine getEngine() {
protected Message retrieveFromContinuation(HttpServletRequest req) {
return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
}
protected void setupContinuation(Message inMessage,
final HttpServletRequest req,
final HttpServletResponse resp) {
if (engine != null && engine.getContinuationsEnabled()) {
super.setupContinuation(inMessage, req, resp);
if (!inMessage.containsKey(ContinuationProvider.class.getName())) {
inMessage.put(ContinuationProvider.class.getName(),
new JettyContinuationProvider(req, resp, inMessage));
}
}
}

private Request getCurrentRequest() {
try {
Expand Down
Loading