openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r1589187 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/
Date Tue, 22 Apr 2014 16:01:57 GMT
Author: kwsutter
Date: Tue Apr 22 16:01:56 2014
New Revision: 1589187

URL: http://svn.apache.org/r1589187
Log:
OPENJPA-2492.  Committing a variation of the patch as provided by Romain Manni-Bucau.  This
patch clears up the ConcurrentHashMap issues relating to the KeySetView return type.  This
patch also adds a couple of asserts to an existing testcase to verify the results.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestConcurrentMap.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java?rev=1589187&r1=1589186&r2=1589187&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
Tue Apr 22 16:01:56 2014
@@ -1331,6 +1331,9 @@ public class ProxyManagerImpl
         Method match;
         Method after;
         for (int i = 0; i < meths.length; i++) {
+            // Java 8 methods with a return type of KeySetView do not need to be proxied
+            if (meths[i].getReturnType().getName().contains("KeySetView")) continue;
+
             params = toHelperParameters(meths[i].getParameterTypes(), 
                 proxyType);
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java?rev=1589187&r1=1589186&r2=1589187&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java Tue
Apr 22 16:01:56 2014
@@ -78,7 +78,8 @@ public class ProxyMaps 
      */
     public static boolean beforeGet(ProxyMap map, Object key) {
         assertAllowedType(key, map.getKeyType());
-        return map.containsKey(key);
+        // Java 8 solution/workaround due to containsKey() calling get!=null, which could
cause infinite loop
+        return map.keySet().contains(key);
     }
 
     /**

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestConcurrentMap.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestConcurrentMap.java?rev=1589187&r1=1589186&r2=1589187&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestConcurrentMap.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestConcurrentMap.java
Tue Apr 22 16:01:56 2014
@@ -44,5 +44,8 @@ public class TestConcurrentMap extends S
         right.getLeftEntityMap().put(left.getStrData(), left);
         
         em.getTransaction().commit();
+        
+        assertEquals(1, right.getLeftEntityMap().size());
+        assertEquals(1, right.getLeftEntityMap().get(left.getStrData()).getId());
     }
 }



Mime
View raw message