openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dazey...@apache.org
Subject svn commit: r1831595 - in /openjpa/branches/2.4.x: openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java
Date Mon, 14 May 2018 22:20:57 GMT
Author: dazeydev
Date: Mon May 14 22:20:56 2018
New Revision: 1831595

URL: http://svn.apache.org/viewvc?rev=1831595&view=rev
Log:
OPENJPA-2646: Fixing test bug to clear cache from other tests

Modified:
    openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java
    openjpa/branches/2.4.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java

Modified: openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java?rev=1831595&r1=1831594&r2=1831595&view=diff
==============================================================================
--- openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java
(original)
+++ openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java
Mon May 14 22:20:56 2018
@@ -186,7 +186,7 @@ public class CacheMap
      * Acquire read lock.
      */
     public void readLock() {
-        _readLock.unlock();
+        _readLock.lock();
     }
 
     /**

Modified: openjpa/branches/2.4.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.4.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java?rev=1831595&r1=1831594&r2=1831595&view=diff
==============================================================================
--- openjpa/branches/2.4.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java
(original)
+++ openjpa/branches/2.4.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparameterization.java
Mon May 14 22:20:56 2018
@@ -89,12 +89,18 @@ public class TestMultithreadedReparamete
         for (Thread thread : threads) {
             thread.join();
         }
-        QueryStatistics<String> stats = emf.getConfiguration().getQuerySQLCacheInstance().getStatistics();
-        for(Throwable t : exceptions) {
-            fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+
+        try {
+            QueryStatistics<String> stats = emf.getConfiguration().getQuerySQLCacheInstance().getStatistics();
+            for(Throwable t : exceptions) {
+                fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+            }
+            assertEquals(nThreads*nRepeats,stats.getExecutionCount(), stats.getExecutionCount(jpql));
+            assertEquals(nThreads*nRepeats-1,stats.getExecutionCount(), stats.getHitCount(jpql));
+        } finally {
+            //clear statistics for other tests
+            emf.getConfiguration().getQuerySQLCacheInstance().clear();
         }
-        assertEquals(nThreads*nRepeats,stats.getExecutionCount(), stats.getExecutionCount(jpql));
-        assertEquals(nThreads*nRepeats-1,stats.getExecutionCount(), stats.getHitCount(jpql));
     }
 
     /**
@@ -157,8 +163,12 @@ public class TestMultithreadedReparamete
                 }
             }
 
-            for(Throwable t : exceptions) {
-                fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+            try {
+                for(Throwable t : exceptions) {
+                    fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+                }
+            } finally {
+                emf.getConfiguration().getQuerySQLCacheInstance().clear();
             }
         }
     }



Mime
View raw message