logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1593085 - /logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java
Date Wed, 07 May 2014 17:55:33 GMT
Author: ggregory
Date: Wed May  7 17:55:33 2014
New Revision: 1593085

URL: http://svn.apache.org/r1593085
Log:
Implement equals() and hashCode(); for XML and JSON receiver testing.

Modified:
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java?rev=1593085&r1=1593084&r2=1593085&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextMap.java
Wed May  7 17:55:33 2014
@@ -164,4 +164,44 @@ public class DefaultThreadContextMap imp
         Map<String, String> map = localMap.get();
         return map == null ? "{}" : map.toString();
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        Map<String, String> map = this.localMap.get();
+        result = prime * result + ((map == null) ? 0 : map.hashCode());
+        result = prime * result + (this.useMap ? 1231 : 1237);
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (obj instanceof DefaultThreadContextMap) {
+            DefaultThreadContextMap other = (DefaultThreadContextMap) obj;
+            if (this.useMap != other.useMap) {
+                return false;
+            }
+        }
+        if (!(obj instanceof ThreadContextMap)) {
+            return false;
+        }
+        ThreadContextMap other = (ThreadContextMap) obj;
+        Map<String, String> map = this.localMap.get();
+        Map<String, String> otherMap = other.getImmutableMapOrNull(); 
+        if (map == null) {
+            if (otherMap != null) {
+                return false;
+            }
+        } else if (!map.equals(otherMap)) {
+            return false;
+        }
+        return true;
+    }
 }



Mime
View raw message