Skip to content

Commit

Permalink
Fixed magro#334: Sort attributes before computing the hashcode
Browse files Browse the repository at this point in the history
  • Loading branch information
51037405 committed Feb 4, 2017
1 parent a5c76aa commit 6486525
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
* <p>
Expand Down Expand Up @@ -590,13 +589,13 @@ public ConcurrentMap<String, Object> getAttributesFiltered() {
}
final Pattern pattern = ((SessionManager)manager).getMemcachedSessionService().getSessionAttributePattern();
final ConcurrentMap<String, Object> attributes = getAttributesInternal();
if ( pattern == null ) {
return attributes;
}
final ConcurrentMap<String, Object> result = new ConcurrentHashMap<String, Object>( attributes.size() );
for ( final Map.Entry<String, Object> 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;
Expand Down

0 comments on commit 6486525

Please sign in to comment.