Author: remy.maucherat(a)jboss.com
Date: 2014-11-18 10:58:06 -0500 (Tue, 18 Nov 2014)
New Revision: 2544
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
Log:
BZ1163126 refix: The inner class used was not actually serializable.
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
===================================================================
---
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-11-17
15:00:02 UTC (rev 2543)
+++
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-11-18
15:58:06 UTC (rev 2544)
@@ -220,7 +220,8 @@
clientIpSessionId.put(clientIp, s.getId());
sessionIdClientIp.put(s.getId(), clientIp);
// #valueUnbound() will be called on session expiration
- s.setAttribute(this.getClass().getName(), new
CrawlerBindingListener());
+ s.setAttribute(this.getClass().getName(),
+ new CrawlerBindingListener(clientIpSessionId,
sessionIdClientIp));
s.setMaxInactiveInterval(sessionInactiveInterval);
if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
@@ -237,18 +238,28 @@
}
}
- protected class CrawlerBindingListener implements HttpSessionBindingListener,
Serializable {
- private static final long serialVersionUID = -3775762684177732270L;
- @Override
- public void valueBound(HttpSessionBindingEvent event) {
- // NOOP
+}
+
+class CrawlerBindingListener implements HttpSessionBindingListener, Serializable {
+ private static final long serialVersionUID = -3775762684177732270L;
+ private final transient Map<String,String> clientIpSessionId;
+ private final transient Map<String,String> sessionIdClientIp;
+
+ CrawlerBindingListener(Map<String,String> clientIpSessionId,
Map<String,String> sessionIdClientIp) {
+ this.clientIpSessionId = clientIpSessionId;
+ this.sessionIdClientIp = sessionIdClientIp;
+ }
+
+ @Override
+ public void valueBound(HttpSessionBindingEvent event) {
+ // NOOP
+ }
+
+ @Override
+ public void valueUnbound(HttpSessionBindingEvent event) {
+ String clientIp = sessionIdClientIp.remove(event.getSession().getId());
+ if (clientIp != null) {
+ clientIpSessionId.remove(clientIp);
}
- @Override
- public void valueUnbound(HttpSessionBindingEvent event) {
- String clientIp = sessionIdClientIp.remove(event.getSession().getId());
- if (clientIp != null) {
- clientIpSessionId.remove(clientIp);
- }
- }
}
}
Show replies by date