From 64865252efe4e40e45cddc92cb2ffa8bf0e1f4b7 Mon Sep 17 00:00:00 2001
From: 51037405 <51037405@qq.com>
Date: Sat, 4 Feb 2017 16:09:29 +0800
Subject: [PATCH 1/2] Fixed #334: Sort attributes before computing the hashcode
---
.../web/msm/MemcachedBackupSession.java | 29 +++++++++----------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java b/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
index d1f821b2..1b103c56 100644
--- a/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
+++ b/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
@@ -16,26 +16,25 @@
*/
package de.javakaffee.web.msm;
+import de.javakaffee.web.msm.MemcachedSessionService.LockStatus;
+import de.javakaffee.web.msm.MemcachedSessionService.SessionManager;
+import org.apache.catalina.Manager;
+import org.apache.catalina.SessionListener;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.session.StandardSession;
+
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.Principal;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
-import org.apache.catalina.Manager;
-import org.apache.catalina.SessionListener;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.session.StandardSession;
-
-import de.javakaffee.web.msm.MemcachedSessionService.LockStatus;
-import de.javakaffee.web.msm.MemcachedSessionService.SessionManager;
-
/**
* The session class used by the {@link MemcachedSessionService}.
*
@@ -590,13 +589,13 @@ public ConcurrentMap getAttributesFiltered() {
}
final Pattern pattern = ((SessionManager)manager).getMemcachedSessionService().getSessionAttributePattern();
final ConcurrentMap attributes = getAttributesInternal();
- if ( pattern == null ) {
- return attributes;
- }
final ConcurrentMap result = new ConcurrentHashMap( attributes.size() );
- for ( final Map.Entry entry: attributes.entrySet() ) {
- if ( pattern.matcher(entry.getKey()).matches() ) {
- result.put( entry.getKey(), entry.getValue() );
+ // sort attributes
+ Object[] attributeKeys = attributes.keySet().toArray();
+ Arrays.sort(attributeKeys);
+ for ( Object attributeKey : attributeKeys ) {
+ if ( pattern == null || pattern.matcher((String )attributeKey).matches() ) {
+ result.put( (String )attributeKey, attributes.get(attributeKey) );
}
}
return result;
From 0a956b36a6adce5e43cdee64639e0effa13110bf Mon Sep 17 00:00:00 2001
From: 51037405 <51037405@qq.com>
Date: Sat, 4 Feb 2017 16:28:11 +0800
Subject: [PATCH 2/2] Fixed #334: Sort attributes before computing the hashcode
---
.../web/msm/MemcachedBackupSession.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java b/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
index 1b103c56..3c14316e 100644
--- a/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
+++ b/core/src/main/java/de/javakaffee/web/msm/MemcachedBackupSession.java
@@ -16,13 +16,6 @@
*/
package de.javakaffee.web.msm;
-import de.javakaffee.web.msm.MemcachedSessionService.LockStatus;
-import de.javakaffee.web.msm.MemcachedSessionService.SessionManager;
-import org.apache.catalina.Manager;
-import org.apache.catalina.SessionListener;
-import org.apache.catalina.authenticator.Constants;
-import org.apache.catalina.session.StandardSession;
-
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -35,6 +28,14 @@
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
+import org.apache.catalina.Manager;
+import org.apache.catalina.SessionListener;
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.session.StandardSession;
+
+import de.javakaffee.web.msm.MemcachedSessionService.LockStatus;
+import de.javakaffee.web.msm.MemcachedSessionService.SessionManager;
+
/**
* The session class used by the {@link MemcachedSessionService}.
*