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 2020/02/23 07:00:37 UTC

[GitHub] [maven] eolivelli commented on a change in pull request #288: [MNG-6773] Slow extension key creation in DefaultExtensionRealmCache under lock

eolivelli commented on a change in pull request #288: [MNG-6773] Slow extension key creation in DefaultExtensionRealmCache under lock
URL: https://github.com/apache/maven/pull/288#discussion_r382970292
 
 

 ##########
 File path: maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
 ##########
 @@ -41,41 +41,46 @@
 public class DefaultExtensionRealmCache
     implements ExtensionRealmCache, Disposable
 {
+
+    private static final ConcurrentHashMap<String, FileInfo> FILE_INFO_CACHE = new ConcurrentHashMap<>( 512 );
+
     /**
      * CacheKey
      */
     protected static class CacheKey
         implements Key
     {
 
-        private final List<File> files;
-
-        private final List<Long> timestamps;
-
-        private final List<Long> sizes;
-
-        private final List<String> ids;
+        private final List<FileInfo> files;
 
         private final int hashCode;
 
         public CacheKey( List<Artifact> extensionArtifacts )
         {
             this.files = new ArrayList<>( extensionArtifacts.size() );
-            this.timestamps = new ArrayList<>( extensionArtifacts.size() );
-            this.sizes = new ArrayList<>( extensionArtifacts.size() );
-            this.ids = new ArrayList<>( extensionArtifacts.size() );
 
             for ( Artifact artifact : extensionArtifacts )
             {
-                File file = artifact.getFile();
-                files.add( file );
-                timestamps.add( ( file != null ) ? Long.valueOf( file.lastModified() ) : Long.valueOf( 0 ) );
-                sizes.add( ( file != null ) ? Long.valueOf( file.length() ) : Long.valueOf( 0 ) );
-                ids.add( artifact.getVersion() );
+                String artifactKey = getArtifactKey( artifact );
+                FileInfo fileInfo = FILE_INFO_CACHE.get( artifactKey );
 
 Review comment:
   What about using computeIfAbsent ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services