You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/09/12 13:16:16 UTC
svn commit: r1522526 - in /tomcat/trunk:
java/org/apache/catalina/valves/CometConnectionManagerValve.java
webapps/docs/changelog.xml
Author: markt
Date: Thu Sep 12 11:16:15 2013
New Revision: 1522526
URL: http://svn.apache.org/r1522526
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52558
Refactor CometConnectionManagerValve so that it does not prevent the session from being serialized in when running in a cluster.
Modified:
tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java?rev=1522526&r1=1522525&r2=1522526&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/CometConnectionManagerValve.java Thu Sep 12 11:16:15 2013
@@ -18,6 +18,7 @@ package org.apache.catalina.valves;
import java.io.IOException;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -177,13 +178,17 @@ public class CometConnectionManagerValve
// Track the connection for session expiration
synchronized (session) {
- Request[] requests = (Request[])
- session.getAttribute(cometRequestsAttribute);
+ ConnectionList list = (ConnectionList) session.getAttribute(
+ cometRequestsAttribute);
+ Request[] requests = null;
+ if (list != null) {
+ requests = list.get();
+ }
if (requests == null) {
requests = new Request[1];
requests[0] = request;
session.setAttribute(cometRequestsAttribute,
- requests);
+ new ConnectionList(requests));
} else {
Request[] newRequests =
new Request[requests.length + 1];
@@ -191,7 +196,8 @@ public class CometConnectionManagerValve
newRequests[i] = requests[i];
}
newRequests[requests.length] = request;
- session.setAttribute(cometRequestsAttribute, newRequests);
+ session.setAttribute(cometRequestsAttribute,
+ new ConnectionList(newRequests));
}
}
}
@@ -235,8 +241,12 @@ public class CometConnectionManagerValve
synchronized (session) {
Request[] reqs = null;
try {
- reqs = (Request[])
- session.getAttribute(cometRequestsAttribute);
+ ConnectionList list =
+ (ConnectionList) session.getAttribute(
+ cometRequestsAttribute);
+ if (list != null) {
+ reqs = list.get();
+ }
} catch (IllegalStateException ise) {
// Ignore - session has been invalidated
// Listener will have cleaned up
@@ -259,7 +269,8 @@ public class CometConnectionManagerValve
try {
session.setAttribute(
cometRequestsAttribute,
- newConnectionInfos);
+ new ConnectionList(
+ newConnectionInfos));
} catch (IllegalStateException ise) {
// Ignore - session has been invalidated
// Listener will have cleaned up
@@ -292,8 +303,12 @@ public class CometConnectionManagerValve
@Override
public void sessionDestroyed(HttpSessionEvent se) {
// Close all Comet connections associated with this session
- Request[] reqs = (Request[])
- se.getSession().getAttribute(cometRequestsAttribute);
+ ConnectionList list = (ConnectionList) se.getSession().getAttribute(
+ cometRequestsAttribute);
+ Request[] reqs = null;
+ if (list != null) {
+ reqs = list.get();
+ }
if (reqs != null) {
for (int i = 0; i < reqs.length; i++) {
Request req = reqs[i];
@@ -312,4 +327,19 @@ public class CometConnectionManagerValve
}
}
+
+ private static class ConnectionList implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient Request[] connectionList = null;
+
+ private ConnectionList(Request[] connectionList){
+ this.connectionList = connectionList;
+ }
+
+ public Request[] get(){
+ return connectionList;
+ }
+ }
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1522526&r1=1522525&r2=1522526&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Sep 12 11:16:15 2013
@@ -91,6 +91,11 @@
<code>AsyncFileHandler</code> by default. (markt)
</update>
<fix>
+ <bug>52558</bug>: Refactor <code>CometConnectionManagerValve</code> so
+ that it does not prevent the session from being serialized in when
+ running in a cluster. (markt)
+ </fix>
+ <fix>
<bug>52767</bug>: Remove reference to MySQL specific autoReconnect
property in <code>JDBCAccessLogValve</code>. (markt)
</fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org