Repository: groovy
Updated Branches:
  refs/heads/master a29598b1c -> d8d551e1d


Check and put entry into `handleCache` atomically


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d8d551e1
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d8d551e1
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d8d551e1

Branch: refs/heads/master
Commit: d8d551e1d656b69bd2e635a34e6c0d102682562a
Parents: a29598b
Author: sunlan <sun...@apache.org>
Authored: Mon Feb 5 08:21:02 2018 +0800
Committer: sunlan <sun...@apache.org>
Committed: Mon Feb 5 08:21:02 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/runtime/ConversionHandler.java   | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d8d551e1/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java 
b/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
index 8bf7c69..db8b919 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
@@ -101,14 +101,11 @@ public abstract class ConversionHandler implements 
InvocationHandler, Serializab
      * @see #invokeCustom(Object, Method, Object[])
      * @see InvocationHandler#invoke(java.lang.Object, 
java.lang.reflect.Method, java.lang.Object[])
      */
-    public Object invoke(Object proxy, Method method, Object[] args) throws 
Throwable {
+    public Object invoke(final Object proxy, Method method, Object[] args) 
throws Throwable {
         if (handleCache != null && isDefaultMethod(method)) {
-            VMPlugin plugin = VMPluginFactory.getPlugin();
-            Object handle = handleCache.get(method);
-            if (handle == null) {
-                handle = plugin.getInvokeSpecialHandle(method, proxy);
-                handleCache.put(method, handle);
-            }
+            final VMPlugin plugin = VMPluginFactory.getPlugin();
+            Object handle = handleCache.computeIfAbsent(method, m -> 
plugin.getInvokeSpecialHandle(m, proxy));
+
             return plugin.invokeHandle(handle, args);
         }
 

Reply via email to