[dna-commits] DNA SVN: r1187 - in trunk: extensions/dna-connector-store-jpa and 5 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Sep 2 14:58:39 EDT 2009


Author: rhauch
Date: 2009-09-02 14:58:39 -0400 (Wed, 02 Sep 2009)
New Revision: 1187

Removed:
   trunk/extensions/dna-web-jcr-rest-war/.settings/org.eclipse.jdt.core.prefs
   trunk/extensions/dna-web-jcr-rest/.settings/org.eclipse.jdt.core.prefs
Modified:
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
   trunk/extensions/dna-connector-store-jpa/pom.xml
   trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
   trunk/extensions/dna-web-jcr-rest-war/.classpath
   trunk/extensions/dna-web-jcr-rest/.classpath
Log:
DNA-509 JPA Connector does not close all EntityManager instances that it creates

Made temporary fix for the JpaSource class to properly close the EntityManagers, as well as the connector framework's AbstractConnectorTest and WritableConnectorTest so that they properly close the RepositorySource instances when finished with each test.  This needs to be cleaned up a little more before this issue can be resolved.

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java	2009-09-02 18:58:39 UTC (rev 1187)
@@ -28,6 +28,7 @@
 import static org.junit.Assert.assertThat;
 import java.io.PrintStream;
 import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -38,6 +39,7 @@
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 import org.jboss.dna.common.statistic.Stopwatch;
+import org.jboss.dna.common.util.Reflection;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.Graph;
@@ -161,11 +163,28 @@
                     connection.close();
                 }
             } finally {
+                openConnections = null;
                 running = false;
                 rootLocation = null;
                 rootUuid = null;
             }
         }
+        if (source != null) {
+            try {
+                Reflection reflection = new Reflection(source.getClass());
+                reflection.invokeBestMethodOnTarget(new String[] {"close"}, source);
+            } catch (NoSuchMethodException err) {
+                // do nothing (method did not exist)
+            } catch (IllegalAccessException err) {
+            } catch (InvocationTargetException err) {
+            } finally {
+                source = null;
+            }
+        }
+        graph = null;
+        context = null;
+        configSource = null;
+        connectionFactory = null;
     }
 
     /**

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java	2009-09-02 18:58:39 UTC (rev 1187)
@@ -47,6 +47,7 @@
 import org.jboss.dna.graph.property.PathNotFoundException;
 import org.jboss.dna.graph.property.PropertyFactory;
 import org.jboss.dna.graph.property.Reference;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -76,6 +77,12 @@
             IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum3.txt"))};
     }
 
+    @Override
+    @After
+    public void afterEach() throws Exception {
+        super.afterEach();
+    }
+
     /**
      * These tests require that the source supports updates, since all of the tests do some form of updates.
      */

Modified: trunk/extensions/dna-connector-store-jpa/pom.xml
===================================================================
--- trunk/extensions/dna-connector-store-jpa/pom.xml	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-connector-store-jpa/pom.xml	2009-09-02 18:58:39 UTC (rev 1187)
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-c3p0</artifactId>
-      <version>3.3.1.GA</version>
+      <version>3.3.2.GA</version>
     </dependency>
     <!-- 
     HSQLDB

Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java	2009-09-02 18:58:39 UTC (rev 1187)
@@ -880,7 +880,8 @@
                     Context context = new InitialContext();
                     dataSource = (DataSource)context.lookup(this.dataSourceJndiName);
                 } catch (Throwable t) {
-                    Logger.getLogger(getClass()).error(t, JpaConnectorI18n.errorFindingDataSourceInJndi, name, dataSourceJndiName);
+                    Logger.getLogger(getClass())
+                          .error(t, JpaConnectorI18n.errorFindingDataSourceInJndi, name, dataSourceJndiName);
                 }
             }
 
@@ -938,11 +939,13 @@
                     setModel(actualModelName);
                 } catch (Throwable e) {
                     // The actual model name doesn't match what's available in the software ...
+                    entityManager.close();
                     entityManagerFactory.close();
                     String msg = JpaConnectorI18n.existingStoreSpecifiesUnknownModel.text(name, actualModelName);
                     throw new RepositorySourceException(msg);
                 }
             }
+            entityManager.close();
             entityManagerFactory.close();
 
             // Now, create another entity manager with the classes from the correct model

Modified: trunk/extensions/dna-web-jcr-rest/.classpath
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.classpath	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-web-jcr-rest/.classpath	2009-09-02 18:58:39 UTC (rev 1187)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
-	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Deleted: trunk/extensions/dna-web-jcr-rest/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.settings/org.eclipse.jdt.core.prefs	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-web-jcr-rest/.settings/org.eclipse.jdt.core.prefs	2009-09-02 18:58:39 UTC (rev 1187)
@@ -1,7 +0,0 @@
-#Wed May 27 16:41:15 EDT 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5

Modified: trunk/extensions/dna-web-jcr-rest-war/.classpath
===================================================================
--- trunk/extensions/dna-web-jcr-rest-war/.classpath	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-web-jcr-rest-war/.classpath	2009-09-02 18:58:39 UTC (rev 1187)
@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
 	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
 		<attributes>
 			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>

Deleted: trunk/extensions/dna-web-jcr-rest-war/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/extensions/dna-web-jcr-rest-war/.settings/org.eclipse.jdt.core.prefs	2009-09-02 18:07:00 UTC (rev 1186)
+++ trunk/extensions/dna-web-jcr-rest-war/.settings/org.eclipse.jdt.core.prefs	2009-09-02 18:58:39 UTC (rev 1187)
@@ -1,7 +0,0 @@
-#Wed May 27 16:41:12 EDT 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5



More information about the dna-commits mailing list