MNG-4916 cache extension plugin resolution errors

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1038917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Igor Fedorenko 2010-11-25 04:30:12 +00:00
parent 1c3abfba3b
commit e260076924
3 changed files with 56 additions and 6 deletions

View File

@ -142,8 +142,16 @@ public class DefaultPluginArtifactsCache
} }
public CacheRecord get( Key key ) public CacheRecord get( Key key )
throws PluginResolutionException
{ {
return cache.get( key ); CacheRecord cacheRecord = cache.get( key );
if ( cacheRecord != null && cacheRecord.exception != null )
{
throw cacheRecord.exception;
}
return cacheRecord;
} }
public CacheRecord put( Key key, List<Artifact> pluginArtifacts ) public CacheRecord put( Key key, List<Artifact> pluginArtifacts )
@ -153,13 +161,34 @@ public class DefaultPluginArtifactsCache
throw new NullPointerException(); throw new NullPointerException();
} }
assertUniqueKey( key );
CacheRecord record =
new CacheRecord( Collections.unmodifiableList( new ArrayList<Artifact>( pluginArtifacts ) ) );
cache.put( key, record );
return record;
}
protected void assertUniqueKey( Key key )
{
if ( cache.containsKey( key ) ) if ( cache.containsKey( key ) )
{ {
throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + key ); throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + key );
} }
}
CacheRecord record = public CacheRecord put( Key key, PluginResolutionException exception )
new CacheRecord( Collections.unmodifiableList( new ArrayList<Artifact>( pluginArtifacts ) ) ); {
if ( exception == null )
{
throw new NullPointerException();
}
assertUniqueKey( key );
CacheRecord record = new CacheRecord( exception );
cache.put( key, record ); cache.put( key, record );

View File

@ -52,20 +52,30 @@ public interface PluginArtifactsCache
public final List<Artifact> artifacts; public final List<Artifact> artifacts;
public final PluginResolutionException exception;
public CacheRecord( List<Artifact> artifacts ) public CacheRecord( List<Artifact> artifacts )
{ {
this.artifacts = artifacts; this.artifacts = artifacts;
this.exception = null;
} }
public CacheRecord( PluginResolutionException exception )
{
this.artifacts = null;
this.exception = exception;
}
} }
Key createKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories, Key createKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories,
RepositorySystemSession session ); RepositorySystemSession session );
CacheRecord get( Key key ); CacheRecord get( Key key ) throws PluginResolutionException;
CacheRecord put( Key key, List<Artifact> pluginArtifacts ); CacheRecord put( Key key, List<Artifact> pluginArtifacts );
CacheRecord put( Key key, PluginResolutionException e );
void flush(); void flush();
/** /**

View File

@ -232,9 +232,20 @@ public class DefaultProjectBuildingHelper
} }
else else
{ {
artifacts = resolveExtensionArtifacts( plugin, project.getRemotePluginRepositories(), request ); try
{
artifacts = resolveExtensionArtifacts( plugin, project.getRemotePluginRepositories(), request );
recordArtifacts = pluginArtifactsCache.put( cacheKey, artifacts ); recordArtifacts = pluginArtifactsCache.put( cacheKey, artifacts );
}
catch ( PluginResolutionException e )
{
pluginArtifactsCache.put( cacheKey, e );
pluginArtifactsCache.register( project, recordArtifacts );
throw e;
}
} }
pluginArtifactsCache.register( project, recordArtifacts ); pluginArtifactsCache.register( project, recordArtifacts );