-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from alparslanavci/concurrent-session-fix/issu…
…e#42 Updated the `findSession` method to fix concurrency issues
- Loading branch information
Showing
5 changed files
with
74 additions
and
112 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
tomcat-core/src/main/java/com/hazelcast/session/LocalSessionsInvalidateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. | ||
*/ | ||
|
||
package com.hazelcast.session; | ||
|
||
import com.hazelcast.core.EntryEvent; | ||
import com.hazelcast.map.listener.EntryEvictedListener; | ||
import com.hazelcast.map.listener.EntryRemovedListener; | ||
import org.apache.catalina.Session; | ||
|
||
import java.util.Map; | ||
|
||
public class LocalSessionsInvalidateListener implements EntryEvictedListener<String, HazelcastSession>, | ||
EntryRemovedListener<String, HazelcastSession> { | ||
|
||
private Map<String, Session> sessions; | ||
|
||
public LocalSessionsInvalidateListener(Map<String, Session> sessions) { | ||
this.sessions = sessions; | ||
} | ||
|
||
@Override | ||
public void entryEvicted(EntryEvent<String, HazelcastSession> event) { | ||
invalidateSessions(event); | ||
} | ||
|
||
@Override | ||
public void entryRemoved(EntryEvent<String, HazelcastSession> event) { | ||
invalidateSessions(event); | ||
} | ||
|
||
private void invalidateSessions(EntryEvent<String, HazelcastSession> entryEvent) { | ||
if (entryEvent.getMember() == null || !entryEvent.getMember().localMember()) { | ||
sessions.remove(entryEvent.getKey()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters