maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherit...@apache.org
Subject [11/50] git commit: o Changed array to atomicreference since arrays are not thread-safe
Date Sat, 01 Dec 2012 14:50:02 GMT
o Changed array to atomicreference since arrays are not thread-safe


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/8c83ae0f
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/8c83ae0f
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/8c83ae0f

Branch: refs/heads/feature/colorized-console/log4j2
Commit: 8c83ae0f8a0d455e1add70c086b5be0ce80c302f
Parents: 94ac1d6
Author: Kristian Rosenvold <kristian.rosenvold@gmail.com>
Authored: Thu Nov 29 22:17:04 2012 +0100
Committer: Arnaud HeĢritier <aheritier@exoplatform.com>
Committed: Sat Dec 1 13:51:05 2012 +0100

----------------------------------------------------------------------
 .../plugin/internal/DefaultLegacySupport.java      |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/8c83ae0f/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java
b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java
index aea0963..53e5f30 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java
@@ -19,9 +19,11 @@ package org.apache.maven.plugin.internal;
  * under the License.
  */
 
+import java.util.concurrent.atomic.AtomicReference;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.LegacySupport;
 import org.codehaus.plexus.component.annotations.Component;
+
 import org.sonatype.aether.RepositorySystemSession;
 
 /**
@@ -37,29 +39,29 @@ public class DefaultLegacySupport
     implements LegacySupport
 {
 
-    private static final ThreadLocal<MavenSession[]> session = new InheritableThreadLocal<MavenSession[]>();
+    private static final ThreadLocal<AtomicReference<MavenSession>> session =
new InheritableThreadLocal<AtomicReference<MavenSession>>();
 
     public void setSession( MavenSession session )
     {
         if ( session == null )
         {
-            MavenSession[] oldSession = DefaultLegacySupport.session.get();
+            AtomicReference<MavenSession> oldSession = DefaultLegacySupport.session.get();
             if ( oldSession != null )
             {
-                oldSession[0] = null;
+                oldSession.set( null);
                 DefaultLegacySupport.session.remove();
             }
         }
         else
         {
-            DefaultLegacySupport.session.set( new MavenSession[] { session } );
+            DefaultLegacySupport.session.set( new AtomicReference<MavenSession>( session
));
         }
     }
 
     public MavenSession getSession()
     {
-        MavenSession[] currentSession = DefaultLegacySupport.session.get();
-        return currentSession != null ? currentSession[0] : null;
+        AtomicReference<MavenSession> currentSession = DefaultLegacySupport.session.get();
+        return currentSession != null ? currentSession.get() : null;
     }
 
     public RepositorySystemSession getRepositorySession()


Mime
View raw message