You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/09/20 22:55:34 UTC
logging-log4j2 git commit: [LOG4J2-1603]
Repository: logging-log4j2
Updated Branches:
refs/heads/master 205d64e41 -> 995e3c3bc
[LOG4J2-1603]
Redo hashCode() and equals() methods in
org.apache.logging.log4j.core.net.ssl classes.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/995e3c3b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/995e3c3b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/995e3c3b
Branch: refs/heads/master
Commit: 995e3c3bcf210f14c796ae6f57e8008d8cfe31b8
Parents: 205d64e
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Sep 20 15:55:30 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Sep 20 15:55:30 2016 -0700
----------------------------------------------------------------------
.../net/ssl/AbstractKeyStoreConfiguration.java | 38 ++++++++++
.../core/net/ssl/KeyStoreConfiguration.java | 30 ++++++++
.../log4j/core/net/ssl/SslConfiguration.java | 77 ++++++++++++++------
.../core/net/ssl/TrustStoreConfiguration.java | 31 ++++++++
src/changes/changes.xml | 3 +
5 files changed, 156 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/995e3c3b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/AbstractKeyStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/AbstractKeyStoreConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/AbstractKeyStoreConfiguration.java
index 57fd791..86bc844 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/AbstractKeyStoreConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/AbstractKeyStoreConfiguration.java
@@ -73,4 +73,42 @@ public class AbstractKeyStoreConfiguration extends StoreConfiguration<KeyStore>
return this.keyStore;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((keyStore == null) ? 0 : keyStore.hashCode());
+ result = prime * result + ((keyStoreType == null) ? 0 : keyStoreType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AbstractKeyStoreConfiguration other = (AbstractKeyStoreConfiguration) obj;
+ if (keyStore == null) {
+ if (other.keyStore != null) {
+ return false;
+ }
+ } else if (!keyStore.equals(other.keyStore)) {
+ return false;
+ }
+ if (keyStoreType == null) {
+ if (other.keyStoreType != null) {
+ return false;
+ }
+ } else if (!keyStoreType.equals(other.keyStoreType)) {
+ return false;
+ }
+ return true;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/995e3c3b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/KeyStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/KeyStoreConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/KeyStoreConfiguration.java
index c5369ea..54c4656 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/KeyStoreConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/KeyStoreConfiguration.java
@@ -72,4 +72,34 @@ public class KeyStoreConfiguration extends AbstractKeyStoreConfiguration {
kmFactory.init(this.getKeyStore(), this.getPasswordAsCharArray());
return kmFactory;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((keyManagerFactoryAlgorithm == null) ? 0 : keyManagerFactoryAlgorithm.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ KeyStoreConfiguration other = (KeyStoreConfiguration) obj;
+ if (keyManagerFactoryAlgorithm == null) {
+ if (other.keyManagerFactoryAlgorithm != null) {
+ return false;
+ }
+ } else if (!keyManagerFactoryAlgorithm.equals(other.keyManagerFactoryAlgorithm)) {
+ return false;
+ }
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/995e3c3b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfiguration.java
index a978f0b..267cc24 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfiguration.java
@@ -204,29 +204,6 @@ public class SslConfiguration {
}
}
- public boolean equals(final SslConfiguration config) {
- if (config == null) {
- return false;
- }
-
- boolean keyStoreEquals = false;
- boolean trustStoreEquals = false;
-
- if (keyStoreConfig != null) {
- keyStoreEquals = keyStoreConfig.equals(config.keyStoreConfig);
- } else {
- keyStoreEquals = keyStoreConfig == config.keyStoreConfig;
- }
-
- if (trustStoreConfig != null) {
- trustStoreEquals = trustStoreConfig.equals(config.trustStoreConfig);
- } else {
- trustStoreEquals = trustStoreConfig == config.trustStoreConfig;
- }
-
- return keyStoreEquals && trustStoreEquals;
- }
-
/**
* Creates an SslConfiguration from a KeyStoreConfiguration and a TrustStoreConfiguration.
* @param protocol The protocol, see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
@@ -243,4 +220,58 @@ public class SslConfiguration {
// @formatter:on
return new SslConfiguration(protocol, keyStoreConfig, trustStoreConfig);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((keyStoreConfig == null) ? 0 : keyStoreConfig.hashCode());
+ result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
+ result = prime * result + ((sslContext == null) ? 0 : sslContext.hashCode());
+ result = prime * result + ((trustStoreConfig == null) ? 0 : trustStoreConfig.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SslConfiguration other = (SslConfiguration) obj;
+ if (keyStoreConfig == null) {
+ if (other.keyStoreConfig != null) {
+ return false;
+ }
+ } else if (!keyStoreConfig.equals(other.keyStoreConfig)) {
+ return false;
+ }
+ if (protocol == null) {
+ if (other.protocol != null) {
+ return false;
+ }
+ } else if (!protocol.equals(other.protocol)) {
+ return false;
+ }
+ if (sslContext == null) {
+ if (other.sslContext != null) {
+ return false;
+ }
+ } else if (!sslContext.equals(other.sslContext)) {
+ return false;
+ }
+ if (trustStoreConfig == null) {
+ if (other.trustStoreConfig != null) {
+ return false;
+ }
+ } else if (!trustStoreConfig.equals(other.trustStoreConfig)) {
+ return false;
+ }
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/995e3c3b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/TrustStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/TrustStoreConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/TrustStoreConfiguration.java
index 7bae22e..d94241b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/TrustStoreConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/TrustStoreConfiguration.java
@@ -70,4 +70,35 @@ public class TrustStoreConfiguration extends AbstractKeyStoreConfiguration {
tmFactory.init(this.getKeyStore());
return tmFactory;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((trustManagerFactoryAlgorithm == null) ? 0 : trustManagerFactoryAlgorithm.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TrustStoreConfiguration other = (TrustStoreConfiguration) obj;
+ if (trustManagerFactoryAlgorithm == null) {
+ if (other.trustManagerFactoryAlgorithm != null) {
+ return false;
+ }
+ } else if (!trustManagerFactoryAlgorithm.equals(other.trustManagerFactoryAlgorithm)) {
+ return false;
+ }
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/995e3c3b/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c657e0b..b42c910 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -168,6 +168,9 @@
<action issue="LOG4J2-1602" dev="ggregory" type="fix">
NPE in org.apache.logging.log4j.core.util.datetime.FormatCache.MultipartKey.equals(Object) when object is null.
</action>
+ <action issue="LOG4J2-1603" dev="ggregory" type="fix">
+ Redo hashCode() and equals() methods in org.apache.logging.log4j.core.net.ssl classes.
+ </action>
<action issue="LOG4J2-1578" dev="ggregory" type="add">
RoutingAppender can be configured with scripts. Add Script in a Routes element.
</action>