https://bz.apache.org/bugzilla/show_bug.cgi?id=63324

--- Comment #4 from Konstantin Kolinko <knst.koli...@gmail.com> ---
Based on the analysis in comment #3 I think that a possible solution is to
adjust the original proposal as follows. I am quoting fragments from attachment
36515

[[[
+    private static class CrawlerHttpSessionBindingListener implements
HttpSessionBindingListener {
+        private final Map<String, String> clientIdSessionId;
+        private final Map<String, String> sessionIdClientId;
]]]

Three changes are needed:

1. Declare CrawlerHttpSessionBindingListener to implement java.io.Serializable.

2. The "clientIdSessionId" field should be declared transient.

3. The "sessionIdClientId" field does not need to be a Map. Just add a String
field "String clientIdentifier" that stores a single value. The field can be
transient as well.

[[[
+        @Override
+        public void valueUnbound(HttpSessionBindingEvent event) {
+            String clientIdentifier =
sessionIdClientId.remove(event.getSession().getId());
+            if (clientIdentifier != null) {
+                clientIdSessionId.remove(clientIdentifier);
+            }
         }
]]]

4. Add a check that clientIdSessionId is not null.

Duplicate removals can he handled by using method Map.remove(key, value) that
removes a key only if the value matches.

if (clientIdentifier != null && clientIdSessionId != null) {
   clientIdSessionId.remove(clientIdentifier, event.getSession().getId());
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to