From fde7831a811b2e35f3b0dc4e8234f2b07ea8214b Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 19 Jul 2011 11:22:32 -0500 Subject: [PATCH] [Bug 352133] resolve java 1.5isms with sessions, fix misspelling in mbean and add access to underlying server in session test server --- .../jetty/server/session/AbstractSession.java | 11 +++++------ .../jetty/server/session/HashSessionIdManager.java | 6 ------ .../jetty/server/session/HashSessionManager.java | 4 +--- .../eclipse/jetty/server/session/HashedSession.java | 1 - .../jetty/server/session/JDBCSessionIdManager.java | 3 +-- .../jetty/server/session/JDBCSessionManager.java | 13 ++++++------- .../session/jmx/AbstractSessionManagerMBean.java | 1 - .../jmx/AbstractSessionManager-mbean.properties | 2 +- .../jetty/server/session/AbstractTestServer.java | 5 +++++ 9 files changed, 19 insertions(+), 27 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java index e1815df32be..0a1ca23e96a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java @@ -18,7 +18,6 @@ import javax.servlet.http.HttpSessionBindingListener; import javax.servlet.http.HttpSessionContext; import javax.servlet.http.HttpSessionEvent; -import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; /** @@ -126,13 +125,13 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI } /* ------------------------------------------------------------ */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public Enumeration getAttributeNames() + @SuppressWarnings({ "unchecked" }) + public Enumeration getAttributeNames() { synchronized (this) { checkValid(); - List names=_attributes==null?Collections.EMPTY_LIST:new ArrayList(_attributes.keySet()); + List names=_attributes==null?Collections.EMPTY_LIST:new ArrayList(_attributes.keySet()); return Collections.enumeration(names); } } @@ -491,7 +490,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI synchronized(this) { HttpSessionEvent event = new HttpSessionEvent(this); - for (Iterator iter = _attributes.values().iterator(); iter.hasNext();) + for (Iterator iter = _attributes.values().iterator(); iter.hasNext();) { Object value = iter.next(); if (value instanceof HttpSessionActivationListener) @@ -509,7 +508,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI synchronized(this) { HttpSessionEvent event = new HttpSessionEvent(this); - for (Iterator iter = _attributes.values().iterator(); iter.hasNext();) + for (Iterator iter = _attributes.values().iterator(); iter.hasNext();) { Object value = iter.next(); if (value instanceof HttpSessionActivationListener) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java index cea21650730..5e0aea6b457 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java @@ -15,23 +15,17 @@ package org.eclipse.jetty.server.session; import java.lang.ref.WeakReference; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ConcurrentMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.eclipse.jetty.server.SessionIdManager; -import org.eclipse.jetty.util.MultiMap; /* ------------------------------------------------------------ */ /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java index fb399fb896e..c015eb283f0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.Map; import java.util.Timer; @@ -32,7 +31,6 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -513,7 +511,7 @@ public class HashSessionManager extends AbstractSessionManager */ DataInputStream in = new DataInputStream(is); String clusterId = in.readUTF(); - String nodeId = in.readUTF(); + in.readUTF(); // nodeId long created = in.readLong(); long accessed = in.readLong(); int requests = in.readInt(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java index 98f0814bc84..07ce2a56c89 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java @@ -9,7 +9,6 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.Enumeration; -import java.util.Map; import javax.servlet.http.HttpServletRequest; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java index ea7da954f93..4493c5bbc32 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java @@ -39,7 +39,6 @@ import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -650,7 +649,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager private void scavenge () { Connection connection = null; - List expiredSessionIds = new ArrayList(); + List expiredSessionIds = new ArrayList(); try { if (__log.isDebugEnabled()) __log.debug("Scavenge sweep started at "+System.currentTimeMillis()); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java index 825e3420675..044e2d88902 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java @@ -24,7 +24,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.ListIterator; @@ -38,7 +37,6 @@ import javax.servlet.http.HttpSessionListener; import org.eclipse.jetty.server.SessionIdManager; import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.log.Log; /** @@ -75,7 +73,7 @@ public class JDBCSessionManager extends AbstractSessionManager protected String __updateSessionAccessTime; protected String __sessionTableRowId; - private ConcurrentHashMap _sessions; + private ConcurrentHashMap _sessions; protected long _saveIntervalSec = 60; //only persist changes to session access times every 60 secs /** @@ -400,7 +398,7 @@ public class JDBCSessionManager extends AbstractSessionManager } @Override - public Class resolveClass (java.io.ObjectStreamClass cl) throws IOException, ClassNotFoundException + public Class resolveClass (java.io.ObjectStreamClass cl) throws IOException, ClassNotFoundException { try { @@ -603,7 +601,7 @@ public class JDBCSessionManager extends AbstractSessionManager prepareTables(); - _sessions = new ConcurrentHashMap(); + _sessions = new ConcurrentHashMap(); super.doStart(); } @@ -771,7 +769,7 @@ public class JDBCSessionManager extends AbstractSessionManager * * @param sessionIds */ - protected void expire (List sessionIds) + protected void expire (List sessionIds) { //don't attempt to scavenge if we are shutting down if (isStopping() || isStopped()) @@ -780,7 +778,7 @@ public class JDBCSessionManager extends AbstractSessionManager //Remove any sessions we already have in memory that match the ids Thread thread=Thread.currentThread(); ClassLoader old_loader=thread.getContextClassLoader(); - ListIterator itor = sessionIds.listIterator(); + ListIterator itor = sessionIds.listIterator(); try { @@ -852,6 +850,7 @@ public class JDBCSessionManager extends AbstractSessionManager final AtomicReference _exception = new AtomicReference(); Runnable load = new Runnable() { + @SuppressWarnings("unchecked") public void run() { SessionData data = null; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/jmx/AbstractSessionManagerMBean.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/jmx/AbstractSessionManagerMBean.java index d507aa14152..4d81b4eab4e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/jmx/AbstractSessionManagerMBean.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/jmx/AbstractSessionManagerMBean.java @@ -16,7 +16,6 @@ package org.eclipse.jetty.server.session.jmx; -import org.eclipse.jetty.jmx.ObjectMBean; import org.eclipse.jetty.server.handler.AbstractHandlerContainer; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.jmx.AbstractHandlerMBean; diff --git a/jetty-server/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties b/jetty-server/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties index 385f28a4201..92deb5f38e3 100644 --- a/jetty-server/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties +++ b/jetty-server/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties @@ -2,7 +2,7 @@ AbstractSessionManager: Abstract Session Manager httpOnly: True if cookies use the http only flag idManager: MObject:RO:The ID Manager instance maxCookieAge: if greater than zero, the time in seconds a session cookie will last for -maxInactiveInterval: default maximim time in seconds a session may be idle +maxInactiveInterval: default maximum time in seconds a session may be idle refreshCookieAge: The time in seconds after which a session cookie is re-set secureCookies: If true, the secure cookie flag is set on session cookies sessionCookie: The set session cookie diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java index cb96434bbc5..87cba0cb0fb 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java @@ -105,4 +105,9 @@ public abstract class AbstractTestServer return context; } + + public Server getServer() + { + return _server; + } }