From beee143f72b0c396591aa0c59739a1e64fd41867 Mon Sep 17 00:00:00 2001 From: Iwao AVE! Date: Tue, 19 May 2020 00:47:30 +0900 Subject: [PATCH] A temporary workaround for Java 8 specific ConcurrentHashMap issue JDK-8161372 https://bugs.openjdk.java.net/browse/JDK-8161372 Should be reverted once the fix is backported or MyBatis drops Java 8 support. --- src/main/java/org/apache/ibatis/binding/MapperProxy.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/apache/ibatis/binding/MapperProxy.java b/src/main/java/org/apache/ibatis/binding/MapperProxy.java index 76268a134d9..2fd67270353 100644 --- a/src/main/java/org/apache/ibatis/binding/MapperProxy.java +++ b/src/main/java/org/apache/ibatis/binding/MapperProxy.java @@ -91,6 +91,14 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl private MapperMethodInvoker cachedInvoker(Method method) throws Throwable { try { + // A workaround for https://bugs.openjdk.java.net/browse/JDK-8161372 + // It should be removed once the fix is backported to Java 8 or + // MyBatis drops Java 8 support. See gh-1929 + MapperMethodInvoker invoker = methodCache.get(method); + if (invoker != null) { + return invoker; + } + return methodCache.computeIfAbsent(method, m -> { if (m.isDefault()) { try {