Pankraz76 commented on code in PR #2428:
URL: https://github.com/apache/maven/pull/2428#discussion_r2125897223


##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java:
##########
@@ -426,29 +425,14 @@ private void removeFromResolutionStack(Key<?> key) {
     }
 
     private static class SingletonScope implements Scope {
-        Map<Key<?>, java.util.function.Supplier<?>> cache = new 
ConcurrentHashMap<>();
+        final Map<Key<?>, java.util.function.Supplier<?>> cache = new 
ConcurrentHashMap<>();
 
         @Nonnull
         @SuppressWarnings("unchecked")
         @Override
         public <T> java.util.function.Supplier<T> scope(
                 @Nonnull Key<T> key, @Nonnull java.util.function.Supplier<T> 
unscoped) {
-            return (java.util.function.Supplier<T>)
-                    cache.computeIfAbsent(key, k -> new 
java.util.function.Supplier<T>() {
-                        volatile T instance;
-
-                        @Override
-                        public T get() {
-                            if (instance == null) {
-                                synchronized (this) {
-                                    if (instance == null) {
-                                        instance = unscoped.get();
-                                    }
-                                }
-                            }
-                            return instance;
-                        }
-                    });
+            return (java.util.function.Supplier<T>) cache.computeIfAbsent(key, 
k -> unscoped);

Review Comment:
   ide suggestion.



-- 
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-unsubscr...@maven.apache.org

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

Reply via email to