Author: rjung
Date: Sat Jun 19 15:59:13 2010
New Revision: 956245
URL: http://svn.apache.org/viewvc?rev=956245&view=rev
Log:
Only use new API for configurable session cookie,
if it is available. Try to stay runtime compatible
with a range of 6.0 versions.
Followup to r953025.
The method using the API is deprecated anyways.
Modified:
tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
Modified:
tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java?rev=956245&r1=956244&r2=956245&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
(original)
+++
tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
Sat Jun 19 15:59:13 2010
@@ -17,6 +17,7 @@
package org.apache.catalina.cluster.session;
import java.io.IOException;
+import java.lang.reflect.Method;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
@@ -459,18 +460,30 @@ public class JvmRouteBinderValve extends
Context context = request.getContext();
if (context.getCookies()) {
// set a new session cookie
- String scName = context.getSessionCookieName();
- if (scName == null) {
- scName = Globals.SESSION_COOKIE_NAME;
+ String scName = Globals.SESSION_COOKIE_NAME;
+ /* Check for TC 6.0.27+ API */
+ Boolean hasCookieAPI = false;
+ Class<?> clazz = context.getClass();
+ try {
+ Method method =
clazz.getDeclaredMethod("getSessionCookieName",
+ new Class[] {});
+ hasCookieAPI = true;
+ } catch (NoSuchMethodException e) {
+ // IGNORE
+ } catch (SecurityException e) {
+ // IGNORE
+ }
+ if (hasCookieAPI && context.getSessionCookieName() != null) {
+ scName = context.getSessionCookieName();
}
Cookie newCookie = new Cookie(scName, sessionId);
-
+
newCookie.setMaxAge(-1);
-
+
String contextPath = null;
if (!response.getConnector().getEmptySessionPath() &&
(context != null)) {
- if (context.getSessionCookiePath() != null) {
+ if (hasCookieAPI && context.getSessionCookiePath() !=
null) {
contextPath = context.getSessionCookiePath();
} else {
contextPath = context.getEncodedPath();
@@ -481,8 +494,8 @@ public class JvmRouteBinderValve extends
} else {
newCookie.setPath("/");
}
-
- if (context.getSessionCookieDomain() != null) {
+
+ if (hasCookieAPI && context.getSessionCookieDomain() != null) {
newCookie.setDomain(context.getSessionCookieDomain());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]