Skip to content

Commit

Permalink
Pass tests on JDK 24
Browse files Browse the repository at this point in the history
JDK 24 does not support SNI for 127.0.0.1 by java.net.http client
GF does not start with JDK 24

Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed Jan 22, 2025
1 parent d88ba31 commit 5ffe8f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -23,6 +23,7 @@
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.client.spi.ConnectorProvider;
import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.jdk.connector.JdkConnectorProvider;
import org.glassfish.jersey.jnh.connector.JavaNetHttpConnectorProvider;
import org.glassfish.jersey.netty.connector.NettyConnectorProvider;
Expand All @@ -48,6 +49,7 @@
public class SniTest {
private static final int PORT = 8443;
private static final String LOCALHOST = "127.0.0.1";
private static JdkVersion jdkVersion = JdkVersion.getJdkVersion();

static {
// Debug
Expand All @@ -58,14 +60,17 @@ public class SniTest {
}

public static ConnectorProvider[] getConnectors() {
return new ConnectorProvider[] {
new NettyConnectorProvider(),
new ApacheConnectorProvider(),
new Apache5ConnectorProvider(),
new JdkConnectorProvider(),
new HttpUrlConnectorProvider(),
new JavaNetHttpConnectorProvider()
};
ConnectorProvider[] providers = new ConnectorProvider[jdkVersion.getMajor() < 24 ? 6 : 5];
providers[0] = new NettyConnectorProvider();
providers[1] = new ApacheConnectorProvider();
providers[2] = new Apache5ConnectorProvider();
providers[3] = new JdkConnectorProvider();
providers[4] = new HttpUrlConnectorProvider();
if (jdkVersion.getMajor() < 24) {
/* The trick with 127.0.0.1 instead of the host in uri to get the SNI does not work for JDK 24 any longer */
providers[5] = new JavaNetHttpConnectorProvider();
}
return providers;
}

@ParameterizedTest
Expand Down Expand Up @@ -122,7 +127,7 @@ public void filter(ClientRequestContext requestContext) throws IOException {
.path("host")
.request();
if (!JavaNetHttpConnectorProvider.class.isInstance(provider)) {
builder = builder.header(HttpHeaders.HOST, hostName + ":8080");
builder = builder.header(HttpHeaders.HOST, hostName + ":" + PORT);
}
try (Response r = builder.get()) {
// empty
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cdi-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<profile>
<id>gf-inject</id>
<activation>
<jdk>[11,)</jdk>
<jdk>[11,24)</jdk>
</activation>
<modules>
<module>gf-cdi-inject</module>
Expand Down

0 comments on commit 5ffe8f9

Please sign in to comment.