jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1519591 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: ConcurrentReadTest.java ConcurrentReadWriteTest.java
Date Tue, 03 Sep 2013 08:16:48 GMT
Author: mduerig
Date: Tue Sep  3 08:16:47 2013
New Revision: 1519591

URL: http://svn.apache.org/r1519591
Log:
OAK-990: ConcurrentRead(Write)Test leaks session

Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java?rev=1519591&r1=1519590&r2=1519591&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadTest.java
Tue Sep  3 08:16:47 2013
@@ -33,25 +33,25 @@ public class ConcurrentReadTest extends 
 
     private static final int READER_COUNT = getScale(20);
 
-    private Session session;
-
-    protected Node root;
-
     @Override
     public void beforeSuite() throws Exception {
-        session = getRepository().login(
+        Session session = getRepository().login(
                 new SimpleCredentials("admin", "admin".toCharArray()));
-        root = session.getRootNode().addNode("testroot", "nt:unstructured");
-        for (int i = 0; i < NODE_COUNT; i++) {
-            Node node = root.addNode("node" + i, "nt:unstructured");
-            for (int j = 0; j < NODE_COUNT; j++) {
-                node.addNode("node" + j, "nt:unstructured");
+        try {
+            Node root = session.getRootNode().addNode("testroot", "nt:unstructured");
+            for (int i = 0; i < NODE_COUNT; i++) {
+                Node node = root.addNode("node" + i, "nt:unstructured");
+                for (int j = 0; j < NODE_COUNT; j++) {
+                    node.addNode("node" + j, "nt:unstructured");
+                }
+                session.save();
             }
-            session.save();
-        }
 
-        for (int i = 0; i < READER_COUNT; i++) {
-            addBackgroundJob(new Reader());
+            for (int i = 0; i < READER_COUNT; i++) {
+                addBackgroundJob(new Reader());
+            }
+        } finally {
+            session.logout();
         }
     }
 
@@ -88,13 +88,20 @@ public class ConcurrentReadTest extends 
 
     @Override
     public void afterSuite() throws Exception {
-        for (int i = 0; i < NODE_COUNT; i++) {
-            root.getNode("node" + i).remove();
+        Session session = getRepository().login(
+                new SimpleCredentials("admin", "admin".toCharArray()));
+        try {
+            Node root = session.getRootNode().getNode("testroot");
+            for (int i = 0; i < NODE_COUNT; i++) {
+                root.getNode("node" + i).remove();
+                session.save();
+            }
+
+            root.remove();
             session.save();
+        } finally {
+            session.logout();
         }
-
-        root.remove();
-        session.save();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java?rev=1519591&r1=1519590&r2=1519591&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadWriteTest.java
Tue Sep  3 08:16:47 2013
@@ -48,12 +48,16 @@ public class ConcurrentReadWriteTest ext
             try {
                 session = getRepository().login(
                         new SimpleCredentials("admin", "admin".toCharArray()));
-                int i = random.nextInt(NODE_COUNT);
-                int j = random.nextInt(NODE_COUNT);
-                Node node = session.getRootNode().getNode(
-                        "testroot/node" + i + "/node" + j);
-                node.setProperty("count", count++);
-                session.save();
+                try {
+                    int i = random.nextInt(NODE_COUNT);
+                    int j = random.nextInt(NODE_COUNT);
+                    Node node = session.getRootNode().getNode(
+                            "testroot/node" + i + "/node" + j);
+                    node.setProperty("count", count++);
+                    session.save();
+                } finally {
+                    session.logout();
+                }
             } catch (RepositoryException e) {
                 throw new RuntimeException(e);
             }



Mime
View raw message