You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/09/13 06:06:02 UTC

[GitHub] [maven] rmannibucau commented on a change in pull request #533: [MNG-7236] The DefaultPluginVersionResolver should cache results for …

rmannibucau commented on a change in pull request #533:
URL: https://github.com/apache/maven/pull/533#discussion_r707028619



##########
File path: maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
##########
@@ -387,6 +404,36 @@ private PluginVersionResult resolveFromProject( PluginVersionRequest request, Li
         return null;
     }
 
+    @SuppressWarnings( "unchecked" )
+    private Map<String, PluginVersionResult> getCache( SessionData data )
+    {
+        Map<String, PluginVersionResult> cache = ( Map<String, PluginVersionResult> ) data.get( CACHE_KEY );
+        while ( cache == null )
+        {
+            cache = new ConcurrentHashMap<>( 256 );
+            if ( data.set( CACHE_KEY, null, cache ) )
+            {
+                break;
+            }
+            cache = ( Map<String, PluginVersionResult> ) data.get( CACHE_KEY );
+        }
+        return cache;
+    }
+
+    private static String getKey( PluginVersionRequest request )
+    {
+        StringBuilder sb = new StringBuilder();
+        sb.append( request.getGroupId() );
+        sb.append( ':' );
+        sb.append( request.getArtifactId() );
+        for ( RemoteRepository repository : request.getRepositories() )

Review comment:
       It is the same for deps since repos can be set in a pom basis (let say gradle repo in a gradle submodule) but this practise triggers all resolutions to happen again since a repo can shadow another one so it looks correct to key the cache like that to me.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org