aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2022-07-15 14:33:23 +0200
committerGitHub <noreply@github.com>2022-07-15 14:33:23 +0200
commit2ced22a372c4a523f6b29e13d6c36cf73a2bc9b5 (patch)
treeedfa991ac607f3ed3c9b80c80421fa1b348554ed
parentff26daaf31ec0567dc6a9049d5e275cf7c4810dc (diff)
parent7ac175f1da9220bc6565e129c2f3dce8ff03b077 (diff)
Merge pull request #23517 from vespa-engine/bjorncs/jdk8-compatv8.19.24
Build vespa-feed-client as multi-release JAR and use reflection as workaround for JDK8
-rw-r--r--vespa-feed-client/pom.xml31
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java8
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/TlsDetailsFactory.java16
-rw-r--r--vespa-feed-client/src/main/java9/ai/vespa/feed/client/impl/TlsDetailsFactory.java20
4 files changed, 66 insertions, 9 deletions
diff --git a/vespa-feed-client/pom.xml b/vespa-feed-client/pom.xml
index 536637bdce2..8b7b82573c4 100644
--- a/vespa-feed-client/pom.xml
+++ b/vespa-feed-client/pom.xml
@@ -53,10 +53,33 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <release>${vespaClients.jdk.releaseVersion}</release>
- <showDeprecation>true</showDeprecation>
- </configuration>
+ <executions>
+ <execution>
+ <id>compile-java-${vespaClients.jdk.releaseVersion}</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <release>${vespaClients.jdk.releaseVersion}</release>
+ <showDeprecation>true</showDeprecation>
+ </configuration>
+ </execution>
+ <execution>
+ <id>compile-java-9</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <release>9</release>
+ <compileSourceRoots>
+ <compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
+ </compileSourceRoots>
+ <outputDirectory>${project.build.outputDirectory}/META-INF/versions/9</outputDirectory>
+ <showDeprecation>true</showDeprecation>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java
index 62cd56f21ce..decb5021f8f 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java
@@ -15,7 +15,6 @@ import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.net.URIAuthority;
import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.reactor.ssl.TlsDetails;
import org.apache.hc.core5.util.Timeout;
import javax.net.ssl.SSLContext;
@@ -131,10 +130,9 @@ class ApacheCluster implements Cluster {
throw new IllegalStateException("No adequate SSL cipher suites supported by the JVM");
ClientTlsStrategyBuilder tlsStrategyBuilder = ClientTlsStrategyBuilder.create()
- .setTlsDetailsFactory(sslEngine ->
- new TlsDetails(sslEngine.getSession(), sslEngine.getApplicationProtocol()))
- .setCiphers(allowedCiphers)
- .setSslContext(sslContext);
+ .setTlsDetailsFactory(TlsDetailsFactory::create)
+ .setCiphers(allowedCiphers)
+ .setSslContext(sslContext);
if (builder.hostnameVerifier != null)
tlsStrategyBuilder.setHostnameVerifier(builder.hostnameVerifier);
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/TlsDetailsFactory.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/TlsDetailsFactory.java
new file mode 100644
index 00000000000..5183ce61761
--- /dev/null
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/TlsDetailsFactory.java
@@ -0,0 +1,16 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client.impl;
+
+import org.apache.hc.core5.reactor.ssl.TlsDetails;
+
+import javax.net.ssl.SSLEngine;
+
+/**
+ * @author bjorncs
+ */
+public class TlsDetailsFactory {
+ private TlsDetailsFactory() {}
+
+ public static TlsDetails create(SSLEngine e) { return new TlsDetails(e.getSession(), "h2"); /*h2 == HTTP2*/ }
+}
+
diff --git a/vespa-feed-client/src/main/java9/ai/vespa/feed/client/impl/TlsDetailsFactory.java b/vespa-feed-client/src/main/java9/ai/vespa/feed/client/impl/TlsDetailsFactory.java
new file mode 100644
index 00000000000..f9903d9943d
--- /dev/null
+++ b/vespa-feed-client/src/main/java9/ai/vespa/feed/client/impl/TlsDetailsFactory.java
@@ -0,0 +1,20 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client.impl;
+
+import org.apache.hc.core5.reactor.ssl.TlsDetails;
+
+import javax.net.ssl.SSLEngine;
+
+/**
+ * {@link SSLEngine#getApplicationProtocol()} is not available on all JDK8 versions
+ * (https://bugs.openjdk.org/browse/JDK-8051498)
+ *
+ * @author bjorncs
+ */
+public class TlsDetailsFactory {
+ private TlsDetailsFactory() {}
+
+ public static TlsDetails create(SSLEngine e) {
+ return new TlsDetails(e.getSession(), e.getApplicationProtocol());
+ }
+}