You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2023/02/08 15:24:20 UTC

[GitHub] [maven-resolver] gnodet commented on a diff in pull request #241: [MRESOLVER-320] Use strong references

gnodet commented on code in PR #241:
URL: https://github.com/apache/maven-resolver/pull/241#discussion_r1100290093


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java:
##########
@@ -80,14 +76,14 @@ public DataPool( RepositorySystemSession session )
 
         if ( cache != null )
         {
-            artifacts = (ObjectPool<Artifact>) cache.get( session, ARTIFACT_POOL );
-            dependencies = (ObjectPool<Dependency>) cache.get( session, DEPENDENCY_POOL );
-            descriptors = (Map<Object, WeakReference<Descriptor>>) cache.get( session, DESCRIPTORS );
+            artifacts = (ConcurrentHashMap<Artifact, Artifact>) cache.get( session, ARTIFACT_POOL );
+            dependencies = (ConcurrentHashMap<Dependency, Dependency>) cache.get( session, DEPENDENCY_POOL );
+            descriptors = (ConcurrentHashMap<Object, Descriptor>) cache.get( session, DESCRIPTORS );

Review Comment:
   Could we add a `computeIfAbsent` method on the `RepositoryCache` to avoid this boilerplate ?
   ```
   Object computeIfAbsent(@Nonnull Object key, @Nonnull Supplier<Object> supplier);
   ```
   so that we can the do
   ```
   artifacts = cache.computeIfAbsent( session, ARTIFACT_POOL, () -> new ConcurrentHashMap<>() );
   ```



-- 
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