Skip to content

Commit

Permalink
Update dependencies to latest (#24)
Browse files Browse the repository at this point in the history
* Update dependencies to latest
Build towards 21 & 22-ea
  • Loading branch information
nhenneaux authored Oct 19, 2023
1 parent d71deb0 commit 4566daf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
java: [ 11, 17, 20 ]
java: [ 17, 21 ]
experimental: [ false ]
include:
- java: 21-ea
- java: 22-ea
os: ubuntu-latest
experimental: true
- java: 21-ea
- java: 22-ea
os: macos-latest
experimental: true
- java: 21-ea
- java: 22-ea
os: windows-latest
experimental: true
name: Build with Java ${{ matrix.java }} on ${{ matrix.os }}
Expand Down
26 changes: 15 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<skipRelease>true</skipRelease>

Expand All @@ -29,10 +29,10 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<jersey.version>3.1.3</jersey.version>
<jetty.version>11.0.15</jetty.version>
<jakarta.xml.version>4.0.1</jakarta.xml.version>
<weld-se-core.version>5.1.1.SP2</weld-se-core.version>
<jersey-httpclient-connector.version>1.1.13</jersey-httpclient-connector.version>
<jetty.version>12.0.2</jetty.version>
<jakarta.xml.version>4.0.2</jakarta.xml.version>
<weld-se-core.version>5.1.2.Final</weld-se-core.version>
<jersey-httpclient-connector.version>1.1.9</jersey-httpclient-connector.version>
</properties>


Expand All @@ -45,7 +45,7 @@

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<artifactId>jetty-http2-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
Expand All @@ -55,8 +55,8 @@
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>

Expand All @@ -69,6 +69,10 @@
<artifactId>osgi-resource-locator</artifactId>
<groupId>org.glassfish.hk2</groupId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -98,7 +102,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.4</version>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -274,7 +278,7 @@
<licenses>
<license>
<name>GNU General Public License (GPL)</name>
<url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
<url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/com/github/nhenneaux/jaxrs/bundle/JettyServer.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.github.nhenneaux.jaxrs.bundle;

import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.util.ExceptionUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
Expand Down Expand Up @@ -45,13 +40,15 @@ public class JettyServer implements AutoCloseable {

JettyServer(int port, TlsSecurityConfiguration tlsSecurityConfiguration, Class<?>... serviceClasses) {
this.server = new Server();
var contexts = new ContextHandlerCollection();
server.setHandler(contexts);
ServerConnector http2Connector =
new ServerConnector(server, getConnectionFactories(tlsSecurityConfiguration));
http2Connector.setPort(port);
server.addConnector(http2Connector);

ServletContextHandler context = new ServletContextHandler(server, "/");

ServletContextHandler context = new ServletContextHandler("/");
contexts.addHandler(context);
final ResourceConfig resourceConfig = new ResourceConfig();
for (Class<?> serviceClass : serviceClasses) {
resourceConfig.register(serviceClass);
Expand All @@ -67,10 +64,10 @@ public class JettyServer implements AutoCloseable {
try {
close();
} catch (RuntimeException closeException) {
MultiException multiException = new MultiException();
ExceptionUtil.MultiException multiException = new ExceptionUtil.MultiException();
multiException.add(e);
multiException.add(closeException);
throw new IllegalStateException(multiException);
multiException.ifExceptionThrowRuntime();
}
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.nhenneaux.jersey.connector.httpclient.HttpClientConnector;
import jakarta.ws.rs.HttpMethod;
import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
Expand Down Expand Up @@ -101,6 +102,13 @@ void testConcurrentGetHttp2JavaHttpClient() throws Exception {
.connectorProvider((jaxRsClient, configuration) -> getHttpClientConnector(jaxRsClient, HttpClient.Version.HTTP_2)), HttpMethod.GET, "/pingWithSleep");
}

@Test
@Timeout(60)
void testConcurrentGetDefaultJavaHttpClient() throws Exception {
testConcurrent(new ClientConfig()
.connectorProvider(HttpClientConnector::new), HttpMethod.GET, "/pingWithSleep");
}

@Test
@Timeout(60)
void testConcurrentHttp1JavaHttpClient() throws Exception {
Expand Down Expand Up @@ -132,21 +140,29 @@ private void testConcurrent(ClientConfig clientConfig, String method, String pat
.trustStore(truststore)
.withConfig(clientConfig)
.build();
client.target("https://localhost:" + port).path(path).request().method(method).close();
final var webTarget = client.target("https://localhost:" + port).path(path);
webTarget.request().method(method).close();

AtomicInteger counter = new AtomicInteger();
final Runnable runnable = () -> {
long start = System.nanoTime();
for (int i = 0; i < iterations; i++) {
try (Response response = client
.target("https://localhost:" + port).path(path).request().method(method)) {
try (Response response = webTarget.request().method(method)) {
response.getStatus();
counter.incrementAndGet();
int reportEveryRequests = 1_000;
if (i % reportEveryRequests == 0) {
System.out.println(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) * 1.0 / reportEveryRequests);
start = System.nanoTime();
}
} catch (ProcessingException e) {
if (e.getMessage().contains("GOAWAY")
|| e.getMessage().contains("Broken pipe") // The HTTP sending process failed with error, Broken pipe
|| e.getMessage().contains(" cancelled")) {// The HTTP sending process failed with error, Stream 673 cancelled
i--;
} else {
throw e;
}
}
}
};
Expand Down

0 comments on commit 4566daf

Please sign in to comment.