Skip to content

Commit

Permalink
Changed to threadsafe Map/Set structures
Browse files Browse the repository at this point in the history
The changed classes have confirmed unsafe concurrent access using failfast-collections

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@906463 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
krosenvold committed Feb 4, 2010
1 parent 7d88357 commit 6c59fce
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
Expand Up @@ -24,6 +24,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
Expand All @@ -49,7 +50,7 @@ public class DefaultArtifactFilterManager

static
{
Set<String> artifacts = new HashSet<String>();
List<String> artifacts = new ArrayList<String>();

artifacts.add( "classworlds" );
artifacts.add( "plexus-classworlds" );
Expand Down Expand Up @@ -86,7 +87,7 @@ public class DefaultArtifactFilterManager
* wagon from their plugin realm.
*/

DEFAULT_EXCLUSIONS = artifacts;
DEFAULT_EXCLUSIONS = new CopyOnWriteArraySet<String>( artifacts);
}

protected Set<String> excludedArtifacts = new HashSet<String>( DEFAULT_EXCLUSIONS );
Expand Down
Expand Up @@ -23,11 +23,11 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryCache;
Expand Down Expand Up @@ -69,6 +69,9 @@ public class MavenSession

private Collection<String> blackListedProjects;

private final Map<String,Map<String,Map<String,Object>>> pluginContextsByProjectAndPluginKey =
new ConcurrentHashMap<String,Map<String,Map<String,Object>>> ();

@Deprecated
public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result, MavenProject project )
{
Expand Down Expand Up @@ -284,8 +287,7 @@ public MavenExecutionResult getResult()
return result;
}

private Map<String,Map<String,Map<String,Object>>> pluginContextsByProjectAndPluginKey = new HashMap<String,Map<String,Map<String,Object>>> ();


// Backward compat
public Map<String, Object> getPluginContext( PluginDescriptor plugin, MavenProject project )
{
Expand All @@ -295,7 +297,7 @@ public Map<String, Object> getPluginContext( PluginDescriptor plugin, MavenProje

if ( pluginContextsByKey == null )
{
pluginContextsByKey = new HashMap<String, Map<String, Object>>();
pluginContextsByKey = new ConcurrentHashMap<String, Map<String, Object>>();

pluginContextsByProjectAndPluginKey.put( projectKey, pluginContextsByKey );
}
Expand All @@ -306,7 +308,7 @@ public Map<String, Object> getPluginContext( PluginDescriptor plugin, MavenProje

if ( pluginContext == null )
{
pluginContext = new HashMap<String, Object>();
pluginContext = new ConcurrentHashMap<String, Object>();

pluginContextsByKey.put( pluginKey, pluginContext );
}
Expand Down
Expand Up @@ -19,8 +19,8 @@
* under the License.
*/

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.artifact.repository.RepositoryCache;
import org.apache.maven.artifact.repository.RepositoryRequest;
Expand All @@ -34,7 +34,7 @@ class SessionRepositoryCache
implements RepositoryCache
{

private Map<Object, Object> cache = new HashMap<Object, Object>( 256 );
private Map<Object, Object> cache = new ConcurrentHashMap<Object, Object>( 256 );

public Object get( RepositoryRequest request, Object key )
{
Expand Down
Expand Up @@ -21,10 +21,10 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
Expand Down Expand Up @@ -105,7 +105,7 @@ && eq( repositories, other.repositories ) && eq( filter, other.filter )
}
}

protected final Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, CacheRecord>();
protected final Map<CacheKey, CacheRecord> cache = new ConcurrentHashMap<CacheKey, CacheRecord>();

public CacheRecord get( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
ArtifactFilter dependencyFilter, ArtifactRepository localRepository,
Expand Down
Expand Up @@ -18,13 +18,13 @@

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
Expand All @@ -38,6 +38,8 @@ public class DefaultMavenMetadataCache
implements MavenMetadataCache
{

protected final Map<CacheKey, CacheRecord> cache = new ConcurrentHashMap<CacheKey, CacheRecord>();

public static class CacheKey
{
private final Artifact artifact;
Expand Down Expand Up @@ -286,7 +288,6 @@ public boolean isStale()
}
}

protected Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, CacheRecord>();

public ResolutionGroup get( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
Expand Down

0 comments on commit 6c59fce

Please sign in to comment.