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/14 15:25:35 UTC

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

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


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java:
##########
@@ -415,4 +440,46 @@ public int hashCode()
             return hashCode;
         }
     }
+
+    private interface InternPool<K, V>
+    {
+        V get( K key );
+
+        V intern( K key, V value );
+    }
+
+    private static class HardInternPool<K, V> implements InternPool<K, V>
+    {
+        private final ConcurrentHashMap<K, V> map = new ConcurrentHashMap<>( 256 );
+
+        @Override
+        public V get( K key )
+        {
+            return map.get( key );
+        }
+
+        @Override
+        public V intern( K key, V value )
+        {
+            return map.computeIfAbsent( key, k -> value );
+        }
+    }
+
+    private static class WeakInternPool<K, V> implements InternPool<K, V>
+    {
+        private final WeakHashMap<K, WeakReference<V>> map = new WeakHashMap<>( 256 );
+
+        @Override
+        public V get( K key )

Review Comment:
   I think it's missing a `synchronized` flag to support concurrent read/write access, as I don't think the `WeakHashMap` does support that.



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DataPool.java:
##########
@@ -53,6 +52,7 @@
  */
 public final class DataPool
 {
+    private static final String CONFIG_PROP_COLLECTOR_POOL_WEAK = "aether.dependencyCollector.pool.weak";

Review Comment:
   Maybe use a non boolean property `aether.dependencyCollector.pool` so that we can experiment with a `weak`, `hard`, `none` ?



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