tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1361802 - /tomcat/trunk/java/org/apache/catalina/session/
Date Sun, 15 Jul 2012 21:18:37 GMT
Author: markt
Date: Sun Jul 15 21:18:36 2012
New Revision: 1361802

URL: http://svn.apache.org/viewvc?rev=1361802&view=rev
Log:
Code clean-up for o.a.catalina.session
 - Add final prompted by UCDetector
 - Java 7 use of <>

Modified:
    tomcat/trunk/java/org/apache/catalina/session/FileStore.java
    tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java
    tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java
    tomcat/trunk/java/org/apache/catalina/session/PersistentManager.java
    tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java
    tomcat/trunk/java/org/apache/catalina/session/StandardManager.java
    tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
    tomcat/trunk/java/org/apache/catalina/session/StandardSessionFacade.java
    tomcat/trunk/java/org/apache/catalina/session/StoreBase.java
    tomcat/trunk/java/org/apache/catalina/session/TooManyActiveSessionsException.java

Modified: tomcat/trunk/java/org/apache/catalina/session/FileStore.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/FileStore.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/FileStore.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/FileStore.java Sun Jul 15 21:18:36 2012
@@ -205,7 +205,7 @@ public final class FileStore extends Sto
         }
 
         // Build and return the list of session identifiers
-        ArrayList<String> list = new ArrayList<String>();
+        ArrayList<String> list = new ArrayList<>();
         int n = FILE_EXT.length();
         for (int i = 0; i < files.length; i++) {
             if (files[i].endsWith(FILE_EXT)) {

Modified: tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/JDBCStore.java Sun Jul 15 21:18:36 2012
@@ -64,12 +64,12 @@ public class JDBCStore extends StoreBase
     /**
      * Name to register for this Store, used for logging.
      */
-    protected static String storeName = "JDBCStore";
+    protected static final String storeName = "JDBCStore";
 
     /**
      * Name to register for the background thread.
      */
-    protected String threadName = "JDBCStore";
+    protected final String threadName = "JDBCStore";
 
     /**
      * The connection username to use when trying to connect to the database.
@@ -490,7 +490,7 @@ public class JDBCStore extends StoreBase
 
                     preparedKeysSql.setString(1, getName());
                     rst = preparedKeysSql.executeQuery();
-                    ArrayList<String> tmpkeys = new ArrayList<String>();
+                    ArrayList<String> tmpkeys = new ArrayList<>();
                     if (rst != null) {
                         while (rst.next()) {
                             tmpkeys.add(rst.getString(1));

Modified: tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/ManagerBase.java Sun Jul 15 21:18:36 2012
@@ -137,10 +137,10 @@ public abstract class ManagerBase extend
     protected static final int TIMING_STATS_CACHE_SIZE = 100;
 
     protected final Deque<SessionTiming> sessionCreationTiming =
-        new LinkedList<SessionTiming>();
+            new LinkedList<>();
 
     protected final Deque<SessionTiming> sessionExpirationTiming =
-        new LinkedList<SessionTiming>();
+            new LinkedList<>();
 
     /**
      * Number of sessions that have expired.
@@ -152,7 +152,7 @@ public abstract class ManagerBase extend
      * The set of currently active Sessions for this Manager, keyed by
      * session identifier.
      */
-    protected Map<String, Session> sessions = new ConcurrentHashMap<String, Session>();
+    protected Map<String, Session> sessions = new ConcurrentHashMap<>();
 
     // Number of sessions created by this manager
     protected long sessionCounter=0;
@@ -978,7 +978,7 @@ public abstract class ManagerBase extend
     @Override
     public int getSessionAverageAliveTime() {
         // Copy current stats
-        List<SessionTiming> copy = new ArrayList<SessionTiming>();
+        List<SessionTiming> copy = new ArrayList<>();
         synchronized (sessionExpirationTiming) {
             copy.addAll(sessionExpirationTiming);
         }
@@ -1014,7 +1014,7 @@ public abstract class ManagerBase extend
     public int getSessionCreateRate() {
         long now = System.currentTimeMillis();
         // Copy current stats
-        List<SessionTiming> copy = new ArrayList<SessionTiming>();
+        List<SessionTiming> copy = new ArrayList<>();
         synchronized (sessionCreationTiming) {
             copy.addAll(sessionCreationTiming);
         }
@@ -1057,7 +1057,7 @@ public abstract class ManagerBase extend
     public int getSessionExpireRate() {
         long now = System.currentTimeMillis();
         // Copy current stats
-        List<SessionTiming> copy = new ArrayList<SessionTiming>();
+        List<SessionTiming> copy = new ArrayList<>();
         synchronized (sessionExpirationTiming) {
             copy.addAll(sessionExpirationTiming);
         }
@@ -1150,7 +1150,7 @@ public abstract class ManagerBase extend
             return null;
         }
 
-        HashMap<String, String> map = new HashMap<String, String>();
+        HashMap<String, String> map = new HashMap<>();
         while (ee.hasMoreElements()) {
             String attrName = ee.nextElement();
             map.put(attrName, getSessionAttribute(sessionId, attrName));

Modified: tomcat/trunk/java/org/apache/catalina/session/PersistentManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/PersistentManager.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/PersistentManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/PersistentManager.java Sun Jul 15 21:18:36
2012
@@ -40,7 +40,7 @@ public final class PersistentManager ext
     /**
      * The descriptive name of this Manager implementation (for logging).
      */
-    protected static String name = "PersistentManager";
+    protected static final String name = "PersistentManager";
 
 
     // ------------------------------------------------------------- Properties

Modified: tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java Sun Jul 15 21:18:36
2012
@@ -134,7 +134,7 @@ public abstract class PersistentManagerB
     /**
      * The descriptive name of this Manager implementation (for logging).
      */
-    private static String name = "PersistentManagerBase";
+    private static final String name = "PersistentManagerBase";
 
 
     /**
@@ -175,8 +175,7 @@ public abstract class PersistentManagerB
     /**
      * Sessions currently being swapped in and the associated locks
      */
-    private final Map<String,Object> sessionSwapInLocks =
-        new HashMap<String,Object>();
+    private final Map<String,Object> sessionSwapInLocks = new HashMap<>();
 
 
     // ------------------------------------------------------------- Properties

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardManager.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardManager.java Sun Jul 15 21:18:36
2012
@@ -342,6 +342,7 @@ public class StandardManager extends Man
      *
      * @exception IOException if an input/output error occurs
      */
+    @SuppressWarnings("null")
     protected void doUnload() throws IOException {
 
         if (log.isDebugEnabled())
@@ -397,11 +398,12 @@ public class StandardManager extends Man
         }
 
         // Write the number of active sessions, followed by the details
-        ArrayList<StandardSession> list = new ArrayList<StandardSession>();
+        ArrayList<StandardSession> list = new ArrayList<>();
         synchronized (sessions) {
             if (log.isDebugEnabled())
                 log.debug("Unloading " + sessions.size() + " sessions");
             try {
+                // oos can't be null here
                 oos.writeObject(new Integer(sessions.size()));
                 Iterator<Session> elements = sessions.values().iterator();
                 while (elements.hasNext()) {

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Sun Jul 15 21:18:36
2012
@@ -152,7 +152,7 @@ public class StandardSession implements 
     /**
      * The collection of user data attributes associated with this Session.
      */
-    protected Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+    protected Map<String, Object> attributes = new ConcurrentHashMap<>();
 
 
     /**
@@ -209,8 +209,7 @@ public class StandardSession implements 
     /**
      * The session event listeners for this Session.
      */
-    protected transient ArrayList<SessionListener> listeners =
-        new ArrayList<SessionListener>();
+    protected transient ArrayList<SessionListener> listeners = new ArrayList<>();
 
 
     /**
@@ -244,7 +243,7 @@ public class StandardSession implements 
      * and event listeners.  <b>IMPLEMENTATION NOTE:</b> This object is
      * <em>not</em> saved and restored across session serializations!
      */
-    protected transient Map<String, Object> notes = new Hashtable<String, Object>();
+    protected transient Map<String, Object> notes = new Hashtable<>();
 
 
     /**
@@ -274,7 +273,7 @@ public class StandardSession implements 
      * The property change support for this component.  NOTE:  This value
      * is not included in the serialized version of this object.
      */
-    protected transient PropertyChangeSupport support =
+    protected final transient PropertyChangeSupport support =
         new PropertyChangeSupport(this);
 
 
@@ -1168,7 +1167,7 @@ public class StandardSession implements 
             throw new IllegalStateException
                 (sm.getString("standardSession.getAttributeNames.ise"));
 
-        Set<String> names = new HashSet<String>();
+        Set<String> names = new HashSet<>();
         names.addAll(attributes.keySet());
         return Collections.enumeration(names);
     }
@@ -1568,7 +1567,7 @@ public class StandardSession implements 
 
         // Deserialize the attribute count and attribute values
         if (attributes == null)
-            attributes = new ConcurrentHashMap<String, Object>();
+            attributes = new ConcurrentHashMap<>();
         int n = ((Integer) stream.readObject()).intValue();
         boolean isValidSave = isValid;
         isValid = true;
@@ -1585,11 +1584,11 @@ public class StandardSession implements 
         isValid = isValidSave;
 
         if (listeners == null) {
-            listeners = new ArrayList<SessionListener>();
+            listeners = new ArrayList<>();
         }
 
         if (notes == null) {
-            notes = new Hashtable<String, Object>();
+            notes = new Hashtable<>();
         }
     }
 
@@ -1629,8 +1628,8 @@ public class StandardSession implements 
 
         // Accumulate the names of serializable and non-serializable attributes
         String keys[] = keys();
-        ArrayList<String> saveNames = new ArrayList<String>();
-        ArrayList<Object> saveValues = new ArrayList<Object>();
+        ArrayList<String> saveNames = new ArrayList<>();
+        ArrayList<Object> saveValues = new ArrayList<>();
         for (int i = 0; i < keys.length; i++) {
             Object value = attributes.get(keys[i]);
             if (value == null)

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSessionFacade.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSessionFacade.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSessionFacade.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSessionFacade.java Sun Jul 15 21:18:36
2012
@@ -32,27 +32,15 @@ import javax.servlet.http.HttpSession;
  * @version $Id$
  */
 
-public class StandardSessionFacade
-    implements HttpSession {
+public class StandardSessionFacade implements HttpSession {
 
 
     // ----------------------------------------------------------- Constructors
 
-
-    /**
-     * Construct a new session facade.
-     */
-    public StandardSessionFacade(StandardSession session) {
-        super();
-        this.session = session;
-    }
-
-
     /**
      * Construct a new session facade.
      */
     public StandardSessionFacade(HttpSession session) {
-        super();
         this.session = session;
     }
 
@@ -63,7 +51,7 @@ public class StandardSessionFacade
     /**
      * Wrapped session object.
      */
-    private HttpSession session = null;
+    private final HttpSession session;
 
 
     // ---------------------------------------------------- HttpSession Methods

Modified: tomcat/trunk/java/org/apache/catalina/session/StoreBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StoreBase.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StoreBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StoreBase.java Sun Jul 15 21:18:36 2012
@@ -43,12 +43,12 @@ public abstract class StoreBase extends 
     /**
      * Name to register for this Store, used for logging.
      */
-    protected static String storeName = "StoreBase";
+    protected static final String storeName = "StoreBase";
 
     /**
      * The property change support for this component.
      */
-    protected PropertyChangeSupport support = new PropertyChangeSupport(this);
+    protected final PropertyChangeSupport support = new PropertyChangeSupport(this);
 
     /**
      * The string manager for this package.

Modified: tomcat/trunk/java/org/apache/catalina/session/TooManyActiveSessionsException.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/TooManyActiveSessionsException.java?rev=1361802&r1=1361801&r2=1361802&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/TooManyActiveSessionsException.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/TooManyActiveSessionsException.java Sun
Jul 15 21:18:36 2012
@@ -20,9 +20,8 @@ package org.apache.catalina.session;
  * An exception that indicates the maximum number of active sessions has been
  * reached and the server is refusing to create any new sessions.
  */
-public class TooManyActiveSessionsException
-    extends IllegalStateException
-{
+public class TooManyActiveSessionsException extends IllegalStateException {
+
     private static final long serialVersionUID = 1L;
 
     /**
@@ -37,11 +36,8 @@ public class TooManyActiveSessionsExcept
      * @param maxActive The maximum number of active sessions allowed by the
      *                  session manager.
      */
-    public TooManyActiveSessionsException(String message,
-                                          int maxActive)
-    {
+    public TooManyActiveSessionsException(String message, int maxActive) {
         super(message);
-
         maxActiveSessions = maxActive;
     }
 
@@ -50,8 +46,7 @@ public class TooManyActiveSessionsExcept
      *
      * @return The maximum number of sessions allowed by the session manager.
      */
-    public int getMaxActiveSessions()
-    {
+    public int getMaxActiveSessions() {
         return maxActiveSessions;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message