jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r995347 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
Date Thu, 09 Sep 2010 08:30:25 GMT
Author: jukka
Date: Thu Sep  9 08:30:24 2010
New Revision: 995347

URL: http://svn.apache.org/viewvc?rev=995347&view=rev
Log:
JCR-2741: Improved logging for session operations

Use the correct Text class and switch to an AtomicLong for the session counter.
Thanks to Julian Sedding for the suggestions!

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java?rev=995347&r1=995346&r2=995347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
Thu Sep  9 08:30:24 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.session;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFactory;
@@ -42,7 +44,7 @@ import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.test.api.util.Text;
+import org.apache.jackrabbit.util.Text;
 
 /**
  * Component context of a session. This class keeps track of the internal
@@ -53,7 +55,7 @@ public class SessionContext implements N
     /**
      * Session counter. Used to generate unique internal session names.
      */
-    private static long counter = 0;
+    private static AtomicLong counter = new AtomicLong();
 
     /**
      * Creates a unique internal session name for a session with the
@@ -62,12 +64,13 @@ public class SessionContext implements N
      * @param userId session user, or <code>null</code>
      * @return session name
      */
-    private static synchronized String createSessionName(String userId) {
+    private static String createSessionName(String userId) {
+        long count = counter.incrementAndGet();
         if (userId != null) {
             String user = Text.escapeIllegalJcrChars(userId);
-            return "session-" + user + "-" + counter++;
+            return "session-" + user + "-" + count;
         } else {
-            return "session-" + counter++;
+            return "session-" + count;
         }
     }
 



Mime
View raw message