You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mk...@apache.org on 2008/01/13 19:19:36 UTC

svn commit: r611615 - in /maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution: DefaultMavenRealmManager.java RealmUtils.java

Author: mkleint
Date: Sun Jan 13 10:19:35 2008
New Revision: 611615

URL: http://svn.apache.org/viewvc?rev=611615&view=rev
Log:
Add Thread.getId()  to the realm identification, a simple trick to make DefaultMavenRealmManager lifecycle safe for paralel execution. 

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RealmUtils.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java?rev=611615&r1=611614&r2=611615&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenRealmManager.java Sun Jan 13 10:19:35 2008
@@ -1,5 +1,24 @@
 package org.apache.maven.execution;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Plugin;
 import org.codehaus.plexus.PlexusContainer;
@@ -35,7 +54,7 @@
 
     private Map pluginArtifacts = new HashMap();
     private Set managedRealmIds = new HashSet();
-
+    
     private final ClassWorld world;
     private final PlexusContainer container;
     private final Logger logger;
@@ -47,7 +66,7 @@
         this.container = container;
         this.logger = logger;
     }
-
+    
     //mkleint: the clearing is fine for sequenced operations. Even though the 
     // MavenRealmManager is associated with request, the paralel execution will
     // eventualy fail as the ClassWorld and PlexusContainer are not meant for 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RealmUtils.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RealmUtils.java?rev=611615&r1=611614&r2=611615&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RealmUtils.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/RealmUtils.java Sun Jan 13 10:19:35 2008
@@ -1,5 +1,24 @@
 package org.apache.maven.execution;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Plugin;
@@ -18,14 +37,16 @@
     public static String createExtensionRealmId( Artifact extensionArtifact )
     {
         return "/extensions/" + extensionArtifact.getGroupId() + ":"
-               + extensionArtifact.getArtifactId() + ":" + extensionArtifact.getVersion();
+               + extensionArtifact.getArtifactId() + ":" + extensionArtifact.getVersion() + 
+               "/thread:" + Thread.currentThread().getId(); //add thread to the mix to prevent clashes in paralel execution
     }
 
     public static String createProjectId( String projectGroupId,
                                           String projectArtifactId,
                                           String projectVersion )
     {
-        return "/projects/" + projectGroupId + ":" + projectArtifactId + ":" + projectVersion;
+        return "/projects/" + projectGroupId + ":" + projectArtifactId + ":" + projectVersion + 
+               "/thread:" + Thread.currentThread().getId(); //add thread to the mix to prevent clashes in paralel execution
     }
 
     public static String createPluginRealmId( Plugin plugin )
@@ -65,7 +86,8 @@
             depId.append( '0' );
         }
 
-        id.append( '@' ).append( depId.toString().hashCode() );
+        id.append( '@' ).append( depId.toString().hashCode() )
+                .append( "/thread:" ).append( Thread.currentThread().getId() ); //add thread to the mix to prevent clashes in paralel execution
 
         return id.toString();
     }