tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1843998 - /tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
Date Tue, 16 Oct 2018 12:17:51 GMT
Author: markt
Date: Tue Oct 16 12:17:50 2018
New Revision: 1843998

URL: http://svn.apache.org/viewvc?rev=1843998&view=rev
Log:
Can't use SSL.version() in static initiator for APR as APR/native library isn't always loaded
when the Connector is created.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1843998&r1=1843997&r2=1843998&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Oct 16 12:17:50
2018
@@ -75,19 +75,32 @@ public class AprEndpoint extends Abstrac
 
     private static final Log log = LogFactory.getLog(AprEndpoint.class);
 
-    protected static final Set<String> SSL_PROTO_ALL = new HashSet<String>();
-
-    static {
-        /* Default used if SSLProtocol is not configured, also
-           used if SSLProtocol="All" */
-        SSL_PROTO_ALL.add(Constants.SSL_PROTO_TLSv1);
-        SSL_PROTO_ALL.add(Constants.SSL_PROTO_TLSv1_1);
-        SSL_PROTO_ALL.add(Constants.SSL_PROTO_TLSv1_2);
-        if (SSL.version() >= 0x1010100f) {
-            SSL_PROTO_ALL.add(Constants.SSL_PROTO_TLSv1_3);
+    // Lazy init as we need the AprLifecycleListener to have loaded the
+    // APR/native library to populate this correctly.
+    private static volatile Set<String> SSL_PROTO_ALL;
+    private static final Object SSL_PROTO_ALL_LOCK = new Object();
+
+    protected static Set<String> getSslProtocolAll() {
+        if (SSL_PROTO_ALL == null) {
+            synchronized (SSL_PROTO_ALL_LOCK) {
+                if (SSL_PROTO_ALL == null) {
+                    Set<String> temp = new HashSet<String>();
+                    /* Default used if SSLProtocol is not configured, also
+                    used if SSLProtocol="All" */
+                    temp.add(Constants.SSL_PROTO_TLSv1);
+                    temp.add(Constants.SSL_PROTO_TLSv1_1);
+                    temp.add(Constants.SSL_PROTO_TLSv1_2);
+                    if (SSL.version() >= 0x1010100f) {
+                        temp.add(Constants.SSL_PROTO_TLSv1_3);
+                    }
+                    SSL_PROTO_ALL = temp;
+                }
+            }
         }
+        return SSL_PROTO_ALL;
     }
 
+
     // ----------------------------------------------------------------- Fields
     /**
      * Root APR memory pool.
@@ -547,7 +560,7 @@ public class AprEndpoint extends Abstrac
                         if (trimmed.charAt(0) == '-') {
                             trimmed = trimmed.substring(1).trim();
                             if (trimmed.equalsIgnoreCase(Constants.SSL_PROTO_ALL)) {
-                                protocols.removeAll(SSL_PROTO_ALL);
+                                protocols.removeAll(getSslProtocolAll());
                             } else {
                                 protocols.remove(trimmed);
                             }
@@ -556,7 +569,7 @@ public class AprEndpoint extends Abstrac
                                 trimmed = trimmed.substring(1).trim();
                             }
                             if (trimmed.equalsIgnoreCase(Constants.SSL_PROTO_ALL)) {
-                                protocols.addAll(SSL_PROTO_ALL);
+                                protocols.addAll(getSslProtocolAll());
                             } else {
                                 protocols.add(trimmed);
                             }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message