diff options
16 files changed, 145 insertions, 86 deletions
diff --git a/README.md b/README.md index 64bd0897d74..8806c49b57e 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Some suggested improvements with pointers to code are in [TODO.md](TODO.md). ### Development environment C++ and Java building is supported on CentOS 7. -The Java source can also be built on any platform having Java 11 and Maven installed. +The Java source can also be built on any platform having Java 17 and Maven installed. Use the following guide to set up a complete development environment using Docker for building Vespa, running unit tests and running system tests: [Vespa development on CentOS 7](https://github.com/vespa-engine/docker-image-dev#vespa-development-on-centos-7). diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml index 5cbed645539..8f9dbd59019 100644 --- a/cloud-tenant-base-dependencies-enforcer/pom.xml +++ b/cloud-tenant-base-dependencies-enforcer/pom.xml @@ -27,7 +27,7 @@ <httpclient.version>4.5.13</httpclient.version> <httpcore.version>4.4.13</httpcore.version> <junit5.version>5.8.1</junit5.version> <!-- TODO: in parent this is named 'junit.version' --> - <onnxruntime.version>1.8.0</onnxruntime.version> + <onnxruntime.version>1.11.0</onnxruntime.version> <!-- END parent/pom.xml --> diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index 4d45398de90..6a9d6b63623 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -70,8 +70,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static com.yahoo.vespa.model.container.component.chain.ProcessingHandler.PROCESSING_HANDLER_CLASS; @@ -130,10 +128,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> public static final BindingPattern VIP_HANDLER_BINDING = SystemBindingPattern.fromHttpPath("/status.html"); - public static final Set<Path> SEARCH_AND_DOCPROC_BUNDLES = Stream.of( - PlatformBundles.SEARCH_AND_DOCPROC_BUNDLE, "container-search-gui", "docprocs", "linguistics-components") - .map(PlatformBundles::absoluteBundlePath).collect(Collectors.toSet()); - private final String name; protected List<CONTAINER> containers = new ArrayList<>(); @@ -404,18 +398,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> return Collections.unmodifiableCollection(allComponents); } - /* - Add all search/docproc/feed related platform bundles. - This is only required for configured containers as the platform bundle set is not allowed to change between config generations. - For standalone container platform bundles can be added on features enabled as an update of application package requires restart. - */ - public void addAllPlatformBundles() { - ContainerDocumentApi.addVespaClientContainerBundle(this); - addSearchAndDocprocBundles(); - } - - public void addSearchAndDocprocBundles() { SEARCH_AND_DOCPROC_BUNDLES.forEach(this::addPlatformBundle); } - private void recursivelyFindAllComponents(Collection<Component<?, ?>> allComponents, AbstractConfigProducer<?> current) { for (AbstractConfigProducer<?> child: current.getChildren().values()) { if (child instanceof Component) @@ -476,9 +458,22 @@ public abstract class ContainerCluster<CONTAINER extends Container> * Adds the Vespa bundles that are necessary for all container types. */ public void addCommonVespaBundles() { - PlatformBundles.commonVespaBundles().forEach(this::addPlatformBundle); + PlatformBundles.commonVespaBundles.forEach(this::addPlatformBundle); } + /* + Add all search/docproc/feed related platform bundles. + This is only required for application configured containers as the platform bundle set is not allowed to change + between config generations. For standalone container platform bundles can be added on features enabled as an + update of application package requires restart. + */ + public void addAllPlatformBundles() { + ContainerDocumentApi.addVespaClientContainerBundle(this); + addSearchAndDocprocBundles(); + } + + public void addSearchAndDocprocBundles() { PlatformBundles.SEARCH_AND_DOCPROC_BUNDLES.forEach(this::addPlatformBundle); } + /** * Adds a bundle present at a known location at the target container nodes. * Note that the set of platform bundles cannot change during the jdisc container's lifetime. diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java index 6a1e647e9be..f8691dcde53 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java @@ -6,12 +6,13 @@ import com.yahoo.vespa.defaults.Defaults; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** + * NOTE: Stable ordering of bundles in config is handled by {@link ContainerCluster#addPlatformBundle(Path)} + * * @author gjoranv * @author Ulf Lilleengen */ @@ -31,11 +32,18 @@ public class PlatformBundles { public static final Path LIBRARY_PATH = Paths.get(Defaults.getDefaults().underVespaHome("lib/jars")); public static final String SEARCH_AND_DOCPROC_BUNDLE = BundleInstantiationSpecification.CONTAINER_SEARCH_AND_DOCPROC; - public static Set<Path> commonVespaBundles() { - var bundles = new LinkedHashSet<Path>(); - commonVespaBundles.stream().map(PlatformBundles::absoluteBundlePath).forEach(bundles::add); - return Collections.unmodifiableSet(bundles); - } + // Bundles that must be loaded for all container types. + public static final Set<Path> commonVespaBundles = Stream.of( + "zkfacade", + "zookeeper-server" // TODO: not necessary in metrics-proxy. + ).map(PlatformBundles::absoluteBundlePath).collect(Collectors.toSet()); + + public static final Set<Path> SEARCH_AND_DOCPROC_BUNDLES = Stream.of( + PlatformBundles.SEARCH_AND_DOCPROC_BUNDLE, + "container-search-gui", + "docprocs", + "linguistics-components" + ).map(PlatformBundles::absoluteBundlePath).collect(Collectors.toSet()); public static Path absoluteBundlePath(String fileName) { return absoluteBundlePath(fileName, JarSuffix.JAR_WITH_DEPS); @@ -50,12 +58,6 @@ public class PlatformBundles { return searchAndDocprocComponents.contains(className); } - // Bundles that must be loaded for all container types. - private static final List<String> commonVespaBundles = List.of( - "zkfacade", - "zookeeper-server" // TODO: not necessary in metrics-proxy. - ); - // This is a hack to allow users to declare components from the search-and-docproc bundle without naming the bundle. private static final Set<String> searchAndDocprocComponents = Set.of( "com.yahoo.docproc.AbstractConcreteDocumentFactory", diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 8f02476b2cc..423d82687a3 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -30,7 +30,6 @@ import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.Zone; -import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.container.logging.FileConnectionLog; import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.schema.OnnxModel; @@ -63,13 +62,13 @@ import com.yahoo.vespa.model.container.PlatformBundles; import com.yahoo.vespa.model.container.SecretStore; import com.yahoo.vespa.model.container.component.AccessLogComponent; import com.yahoo.vespa.model.container.component.BindingPattern; +import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.ConnectionLogComponent; import com.yahoo.vespa.model.container.component.FileStatusHandlerComponent; import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.SimpleComponent; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.component.UserBindingPattern; -import com.yahoo.vespa.model.container.component.chain.ProcessingHandler; import com.yahoo.vespa.model.container.docproc.ContainerDocproc; import com.yahoo.vespa.model.container.docproc.DocprocChains; import com.yahoo.vespa.model.container.http.AccessControl; @@ -89,6 +88,7 @@ import com.yahoo.vespa.model.container.xml.embedder.EmbedderConfig; import com.yahoo.vespa.model.content.StorageGroup; import org.w3c.dom.Element; import org.w3c.dom.Node; + import java.net.URI; import java.security.cert.X509Certificate; import java.util.ArrayList; @@ -886,16 +886,13 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } private void addSearchHandler(ApplicationContainerCluster cluster, Element searchElement) { - // Magic spell is needed to receive the chains config :-| - cluster.addComponent(new ProcessingHandler<>( - cluster.getSearch().getChains(), - BundleInstantiationSpecification.fromSearchAndDocproc("com.yahoo.search.searchchain.ExecutionFactory"))); - - cluster.addComponent( - new SearchHandler( - cluster, - serverBindings(searchElement, SearchHandler.DEFAULT_BINDING), - ContainerThreadpool.UserOptions.fromXml(searchElement).orElse(null))); + SearchHandler searchHandler = new SearchHandler(cluster, + serverBindings(searchElement, SearchHandler.DEFAULT_BINDING), + ContainerThreadpool.UserOptions.fromXml(searchElement).orElse(null)); + cluster.addComponent(searchHandler); + + // Add as child to SearchHandler to get the correct chains config. + searchHandler.addComponent(Component.fromClassAndBundle(SearchHandler.EXECUTION_FACTORY_CLASS, PlatformBundles.SEARCH_AND_DOCPROC_BUNDLE)); } private void addGUIHandler(ApplicationContainerCluster cluster) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java index 7e1b3be9240..54cd061d2c5 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/SearchHandler.java @@ -5,7 +5,6 @@ import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.container.handler.threadpool.ContainerThreadpoolConfig; import com.yahoo.vespa.model.container.ApplicationContainerCluster; import com.yahoo.vespa.model.container.ContainerThreadpool; -import com.yahoo.vespa.model.container.PlatformBundles; import com.yahoo.vespa.model.container.component.BindingPattern; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.component.chain.ProcessingHandler; @@ -23,6 +22,8 @@ import static com.yahoo.container.bundle.BundleInstantiationSpecification.fromSe class SearchHandler extends ProcessingHandler<SearchChains> { static final String HANDLER_CLASS = com.yahoo.search.handler.SearchHandler.class.getName(); + static final String EXECUTION_FACTORY_CLASS = com.yahoo.search.searchchain.ExecutionFactory.class.getName(); + static final BundleInstantiationSpecification HANDLER_SPEC = fromSearchAndDocproc(HANDLER_CLASS); static final BindingPattern DEFAULT_BINDING = SystemBindingPattern.fromHttpPath("/search/*"); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java index c41373b9f85..e6e580b9baa 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java @@ -9,6 +9,7 @@ import com.yahoo.container.jdisc.JdiscBindingsConfig; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.container.ApplicationContainerCluster; import com.yahoo.vespa.model.container.ContainerCluster; +import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.search.GUIHandler; import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils; @@ -39,13 +40,7 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { @Test public void gui_search_handler_is_always_included_when_search_is_specified() { - Element clusterElem = DomBuilderTest.parse( - "<container id='default' version='1.0'>", - " <search />", - nodesXml, - "</container>"); - - createModel(root, clusterElem); + createBasicSearchModel(); String discBindingsConfig = root.getConfig(JdiscBindingsConfig.class, "default").toString(); assertTrue(discBindingsConfig.contains(GUIHandler.BINDING_PATH)); @@ -190,7 +185,7 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { VespaModel model = getVespaModelWithMusic(hosts, services); - ContainerCluster cluster = model.getContainerClusters().get("container"); + ApplicationContainerCluster cluster = model.getContainerClusters().get("container"); assertFalse(cluster.getSearchChains().localProviders().isEmpty()); } @@ -216,19 +211,13 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { VespaModel model = getVespaModelWithMusic(hosts, services); - ContainerCluster cluster = model.getContainerClusters().get("container"); + ApplicationContainerCluster cluster = model.getContainerClusters().get("container"); assertFalse(cluster.getSearchChains().localProviders().isEmpty()); } @Test public void search_handler_has_dedicated_threadpool() { - Element clusterElem = DomBuilderTest.parse( - "<container id='default' version='1.0'>", - " <search />", - nodesXml, - "</container>"); - - createModel(root, clusterElem); + createBasicSearchModel(); Handler searchHandler = getHandler("default", SearchHandler.HANDLER_CLASS); assertTrue(searchHandler.getInjectedComponentIds().contains("threadpool@search-handler")); @@ -261,10 +250,30 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { assertEquals(10, config.queueSize()); } + @Test + public void ExecutionFactory_gets_same_chains_config_as_SearchHandler() { + createBasicSearchModel(); + Component<?,?> executionFactory = ((SearchHandler) getComponent("default",SearchHandler.HANDLER_CLASS)) + .getChildren().get(SearchHandler.EXECUTION_FACTORY_CLASS); + + ChainsConfig executionFactoryChainsConfig = root.getConfig(ChainsConfig.class, executionFactory.getConfigId()); + assertEquals(chainsConfig(), executionFactoryChainsConfig); + } + private VespaModel getVespaModelWithMusic(String hosts, String services) { return new VespaModelCreatorWithMockPkg(hosts, services, ApplicationPackageUtils.generateSchemas("music")).create(); } + private void createBasicSearchModel() { + Element clusterElem = DomBuilderTest.parse( + "<container id='default' version='1.0'>", + " <search />", + nodesXml, + "</container>"); + + createModel(root, clusterElem); + } + private String hostsXml() { return "" + "<hosts> " + diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index ad1827df628..0a8733fb124 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -332,7 +332,7 @@ public class Flags { public static final UnboundBooleanFlag ENABLE_DATA_HIGHWAY_IN_AWS = defineFeatureFlag( "enable-data-highway-in-aws", false, - List.of("hmusum"), "2022-01-06", "2022-08-01", + List.of("hmusum"), "2022-01-06", "2022-09-01", "Enable Data Highway in AWS", "Takes effect on restart of Docker container", ZONE_ID, APPLICATION_ID); @@ -410,7 +410,7 @@ public class Flags { public static final UnboundStringFlag APPLICATION_FILES_WITH_UNKNOWN_EXTENSION = defineStringFlag( "fail-deployment-for-files-with-unknown-extension", "LOG", - List.of("hmusum"), "2022-04-27", "2022-07-27", + List.of("hmusum"), "2022-04-27", "2022-09-01", "Whether to log, fail or do nothing for deployments when app has a file with unknown extension (valid values LOG, FAIL, NOOP)", "Takes effect at redeployment", ZONE_ID, APPLICATION_ID); diff --git a/parent/pom.xml b/parent/pom.xml index 1536ef9cb53..05060c57ec9 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1032,7 +1032,7 @@ <maven-site-plugin.version>3.9.1</maven-site-plugin.version> <maven-source-plugin.version>3.2.1</maven-source-plugin.version> <mockito.version>4.0.0</mockito.version> - <onnxruntime.version>1.8.0</onnxruntime.version> <!-- WARNING: sync cloud-tenant-base-dependencies-enforcer/pom.xml --> + <onnxruntime.version>1.11.0</onnxruntime.version> <!-- WARNING: sync cloud-tenant-base-dependencies-enforcer/pom.xml --> <org.lz4.version>1.8.0</org.lz4.version> <prometheus.client.version>0.6.0</prometheus.client.version> <protobuf.version>3.19.2</protobuf.version> diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp index 37d04f6bcb9..ecdc679e4bc 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp @@ -164,13 +164,15 @@ BucketDB::isActiveBucket(const BucketId &bucketId) const return (itr != _map.end()) && itr->second.isActive(); } -void -BucketDB::getBuckets(BucketId::List &buckets) const +document::BucketId::List +BucketDB::getBuckets() const { + BucketId::List buckets; buckets.reserve(_map.size()); for (const auto & entry : _map) { buckets.push_back(entry.first); } + return buckets; } bool @@ -261,8 +263,8 @@ BucketDB::populateActiveBuckets(BucketId::List buckets) BucketState activeState; activeState.setActive(true); for (const BucketId & bucketId : toAdd) { - InsertResult ins(_map.emplace(bucketId, activeState)); - assert(ins.second); + auto [itr, inserted] = _map.emplace(bucketId, activeState); + assert(inserted); } return fixupBuckets; } diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h index 6fe46d97f46..da475f2969a 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h @@ -20,9 +20,7 @@ public: typedef storage::spi::BucketChecksum BucketChecksum; typedef bucketdb::BucketState BucketState; typedef std::map<BucketId, BucketState> Map; - typedef Map::iterator MapIterator; typedef Map::const_iterator ConstMapIterator; - typedef std::pair<MapIterator, bool> InsertResult; private: Map _map; @@ -58,7 +56,7 @@ public: storage::spi::BucketInfo cachedGetBucketInfo(const BucketId &bucketId) const; BucketState cachedGet(const BucketId &bucketId) const; bool hasBucket(const BucketId &bucketId) const; - void getBuckets(BucketId::List & buckets) const; + BucketId::List getBuckets() const; bool empty() const; void setBucketState(const BucketId &bucketId, bool active); void createBucket(const BucketId &bucketId); @@ -69,7 +67,6 @@ public: ConstMapIterator begin() const { return _map.begin(); } ConstMapIterator end() const { return _map.end(); } ConstMapIterator lowerBound(const BucketId &bucket) const { return _map.lower_bound(bucket); } - ConstMapIterator upperBound(const BucketId &bucket) const { return _map.upper_bound(bucket); } size_t size() const { return _map.size(); } bool isActiveBucket(const BucketId &bucketId) const; BucketState *getBucketStatePtr(const BucketId &bucket); diff --git a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp index d9201ce5b9e..080d182d1fa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp @@ -90,8 +90,7 @@ BucketHandler::handleListBuckets(IBucketIdListResultHandler &resultHandler) // Called by SPI thread. // BucketDBOwner ensures synchronization between SPI thread and // master write thread in document database. - BucketIdListResult::List buckets; - _ready->getBucketDB().takeGuard()->getBuckets(buckets); + BucketIdListResult::List buckets = _ready->getBucketDB().takeGuard()->getBuckets(); resultHandler.handle(BucketIdListResult(std::move(buckets))); } 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()); + } +} |