AlexanderAshitkin 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_r383081417
##########
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:
Hi reworked a bit - as it doesn't make much sense to access file system at
all, i removed that part. to restore previous behavior in case of issues new
command line flag introduced
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services