lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:jira/http2: Auto switch to http/1 when ssl is enabled
Date Sun, 02 Dec 2018 20:55:41 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/http2 18e909690 -> bb5955f51


Auto switch to http/1 when ssl is enabled


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/bb5955f5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/bb5955f5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/bb5955f5

Branch: refs/heads/jira/http2
Commit: bb5955f5159ff167ac655b71f87b8b4b1ef805ab
Parents: 18e9096
Author: Cao Manh Dat <datcm@apache.org>
Authored: Sun Dec 2 20:55:30 2018 +0000
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Sun Dec 2 20:55:30 2018 +0000

----------------------------------------------------------------------
 .../client/solrj/embedded/JettySolrRunner.java   |  3 ++-
 .../solr/client/solrj/impl/Http2SolrClient.java  | 19 +++++++++++--------
 .../java/org/apache/solr/util/RandomizeSSL.java  |  3 ---
 3 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb5955f5/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
index ccc91fe..61b0f95 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
@@ -45,6 +45,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.lucene.util.Constants;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.cloud.SocketProxy;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
@@ -284,7 +285,7 @@ public class JettySolrRunner {
         configuration.addCustomizer(new SecureRequestCustomizer());
         HttpConnectionFactory http1ConnectionFactory = new HttpConnectionFactory(configuration);
 
-        if (config.onlyHttp1) {
+        if (config.onlyHttp1 || !Constants.JRE_IS_MINIMUM_JAVA9) {
           connector = new ServerConnector(server, new SslConnectionFactory(sslcontext,
               http1ConnectionFactory.getProtocol()),
               http1ConnectionFactory);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb5955f5/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 4add0f8..020aea6 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -174,24 +174,27 @@ public class Http2SolrClient extends SolrClient {
     httpClientExecutor.setDaemon(true);
 
     SslContextFactory sslContextFactory;
+    boolean ssl;
     if (builder.sslConfig == null) {
       sslContextFactory = getDefaultSslContextFactory();
+      ssl = sslContextFactory.getTrustStore() != null || sslContextFactory.getTrustStorePath()
!= null;
     } else {
       sslContextFactory = builder.sslConfig.createContextFactory();
+      ssl = true;
     }
 
+    boolean sslOnJava8OrLower = ssl && !Constants.JRE_IS_MINIMUM_JAVA9;
     HttpClientTransport transport;
-    if (builder.useHttp1_1) {
-      log.debug("Create Http2SolrClient with HTTP/1.1 transport");
+    if (builder.useHttp1_1 || sslOnJava8OrLower) {
+      if (sslOnJava8OrLower && !builder.useHttp1_1) {
+        log.warn("Create Http2SolrClient with HTTP/1.1 transport since Java 8 or lower versions
does not support SSL + HTTP/2");
+      } else {
+        log.debug("Create Http2SolrClient with HTTP/1.1 transport");
+      }
       transport = new HttpClientTransportOverHTTP(2);
       httpClient = new HttpClient(transport, sslContextFactory);
       if (builder.maxConnectionsPerHost != null) httpClient.setMaxConnectionsPerDestination(builder.maxConnectionsPerHost);
     } else {
-      if (sslContextFactory.getTrustStore() != null || sslContextFactory.getTrustStorePath()
!= null) {
-        if (!Constants.JRE_IS_MINIMUM_JAVA9) {
-          throw new IllegalArgumentException("SSL + HTTP/2 can only run on Java 9 or latter
versions");
-        }
-      }
       log.debug("Create Http2SolrClient with HTTP/2 transport");
       HTTP2Client http2client = new HTTP2Client();
       transport = new HttpClientTransportOverHTTP2(http2client);
@@ -381,7 +384,7 @@ public class Http2SolrClient extends SolrClient {
       try {
         InputStreamResponseListener listener = new InputStreamResponseListener();
         req.send(listener);
-        Response response = listener.get(idleTimeout, TimeUnit.SECONDS);
+        Response response = listener.get(idleTimeout, TimeUnit.MILLISECONDS);
         InputStream is = listener.getInputStream();
         assert ObjectReleaseTracker.track(is);
         return processErrorsAndResponse(response, parser, is, getEncoding(response), isV2ApiRequest(solrRequest));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bb5955f5/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java b/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java
index b6ca51c..57fa8c3 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/RandomizeSSL.java
@@ -137,9 +137,6 @@ public @interface RandomizeSSL {
      * Returns an SSLRandomizer suitable for the specified (test) class
      */
     public static final SSLRandomizer getSSLRandomizerForClass(Class clazz) {
-      if (!Constants.JRE_IS_MINIMUM_JAVA9) {
-        return new SSLRandomizer(0.0D, 0.0D, "Only Java9 or latter versions support SSL with
HTTP/2");
-      }
 
       final SuppressSSL suppression = (SuppressSSL) clazz.getAnnotation(SuppressSSL.class);
       if (null != suppression) {


Mime
View raw message