gnodet commented on a change in pull request #533:
URL: https://github.com/apache/maven/pull/533#discussion_r707134977
##########
File path:
maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
##########
@@ -408,34 +408,64 @@ private PluginVersionResult resolveFromProject(
PluginVersionRequest request, Li
}
@SuppressWarnings( "unchecked" )
- private ConcurrentMap<String, PluginVersionResult> getCache( SessionData
data )
+ private ConcurrentMap<Key, PluginVersionResult> getCache( SessionData data
)
{
- ConcurrentMap<String, PluginVersionResult> cache =
- ( ConcurrentMap<String, PluginVersionResult> ) data.get(
CACHE_KEY );
+ ConcurrentMap<Key, PluginVersionResult> cache =
+ ( ConcurrentMap<Key, PluginVersionResult> ) data.get(
CACHE_KEY );
while ( cache == null )
{
cache = new ConcurrentHashMap<>( 256 );
if ( data.set( CACHE_KEY, null, cache ) )
{
break;
}
- cache = ( ConcurrentMap<String, PluginVersionResult> ) data.get(
CACHE_KEY );
+ cache = ( ConcurrentMap<Key, PluginVersionResult> ) data.get(
CACHE_KEY );
}
return cache;
}
- private static String getKey( PluginVersionRequest request )
+ private static Key getKey( PluginVersionRequest request )
{
- StringBuilder sb = new StringBuilder();
- sb.append( request.getGroupId() );
- sb.append( ':' );
- sb.append( request.getArtifactId() );
- for ( RemoteRepository repository : request.getRepositories() )
+ return new Key( request.getGroupId(), request.getArtifactId(),
request.getRepositories() );
+ }
+
+ static class Key
+ {
+ final String groupId;
+ final String artifactId;
+ final List<RemoteRepository> repositories;
+ final int hash;
+
+ Key( String groupId, String artifactId, List<RemoteRepository>
repositories )
Review comment:
I don't think so, the key assumes a given request will always lead to
the same result, which is the point of the cache. There's no assumption about
how the plugin version is used.
Note that the PluginVersionResolver is only used when the version is not
specified in which case, it will request metadata to the remote repositories
and select the highest version. The assumption is that during the lifetime of
the maven session, the remote repositories will always return the same metadata.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]