You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2017/05/23 08:49:57 UTC

[14/14] logging-log4j2 git commit: LOG4J2-1442 fix configuration

LOG4J2-1442 fix configuration


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/bbf76968
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/bbf76968
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/bbf76968

Branch: refs/heads/master
Commit: bbf7696855b86d2bfe51b12693edb633cbe02c73
Parents: 8c10f78
Author: Mikael Ståldal <mi...@magine.com>
Authored: Tue May 23 10:04:59 2017 +0200
Committer: Mikael Ståldal <mi...@magine.com>
Committed: Tue May 23 10:04:59 2017 +0200

----------------------------------------------------------------------
 .../log4j/core/appender/HttpURLConnectionManager.java       | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bbf76968/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/HttpURLConnectionManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/HttpURLConnectionManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/HttpURLConnectionManager.java
index a47684e..923b15f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/HttpURLConnectionManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/HttpURLConnectionManager.java
@@ -43,6 +43,7 @@ public class HttpURLConnectionManager extends HttpManager {
     private static final Charset CHARSET = Charset.forName("US-ASCII");
 
     private final URL url;
+    private final boolean isHttps;
     private final String method;
     private final int connectTimeoutMillis;
     private final int readTimeoutMillis;
@@ -63,17 +64,15 @@ public class HttpURLConnectionManager extends HttpManager {
         } catch (MalformedURLException e) {
             throw new ConfigurationException(e);
         }
+        this.isHttps = this.url.getProtocol().equalsIgnoreCase("https");
         this.method = Objects.requireNonNull(method, "method");
         this.connectTimeoutMillis = connectTimeoutMillis;
         this.readTimeoutMillis = readTimeoutMillis;
         this.headers = headers != null ? headers : new Property[0];
         this.sslConfiguration = sslConfiguration;
-        if (this.sslConfiguration != null && !this.url.getProtocol().equalsIgnoreCase("https")) {
+        if (this.sslConfiguration != null && !isHttps) {
             throw new ConfigurationException("SSL configuration can only be specified with URL scheme https");
         }
-        if (!this.verifyHostname && !this.url.getProtocol().equalsIgnoreCase("https")) {
-            throw new ConfigurationException("verifyHostname=false can only be specified with URL scheme https");
-        }
     }
 
     @Override
@@ -94,7 +93,7 @@ public class HttpURLConnectionManager extends HttpManager {
         if (sslConfiguration != null) {
             ((HttpsURLConnection)urlConnection).setSSLSocketFactory(sslConfiguration.getSslSocketFactory());
         }
-        if (!verifyHostname) {
+        if (isHttps && !verifyHostname) {
             ((HttpsURLConnection)urlConnection).setHostnameVerifier(LaxHostnameVerifier.INSTANCE);
         }