Author: dwoods
Date: Wed Sep 29 21:43:11 2010
New Revision: 1002860
URL: http://svn.apache.org/viewvc?rev=1002860&view=rev
Log:
OPENJPA-1764 Need to explicitly close dbcp.BasicDataSource instances, moved
commons-dbcp test depend to parent pom and added closing of EMF in
ContainerTest during test tearDown.
Modified:
openjpa/trunk/openjpa-integration/daytrader/pom.xml
openjpa/trunk/openjpa-integration/validation/pom.xml
openjpa/trunk/openjpa-jdbc/pom.xml
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
openjpa/trunk/openjpa-persistence-jdbc/pom.xml
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jta/ContainerTest.java
openjpa/trunk/openjpa-persistence-locking/pom.xml
openjpa/trunk/pom.xml
Modified: openjpa/trunk/openjpa-integration/daytrader/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/daytrader/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/daytrader/pom.xml (original)
+++ openjpa/trunk/openjpa-integration/daytrader/pom.xml Wed Sep 29 21:43:11 2010
@@ -70,22 +70,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>jakarta-regexp</groupId>
<artifactId>jakarta-regexp</artifactId>
<scope>test</scope>
Modified: openjpa/trunk/openjpa-integration/validation/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/pom.xml (original)
+++ openjpa/trunk/openjpa-integration/validation/pom.xml Wed Sep 29 21:43:11
2010
@@ -79,11 +79,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
Modified: openjpa/trunk/openjpa-jdbc/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/pom.xml (original)
+++ openjpa/trunk/openjpa-jdbc/pom.xml Wed Sep 29 21:43:11 2010
@@ -62,7 +62,11 @@
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>8.4-701.jdbc3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
---
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
(original)
+++
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
Wed Sep 29 21:43:11 2010
@@ -29,6 +29,7 @@ import org.apache.openjpa.jdbc.conf.JDBC
import org.apache.openjpa.lib.conf.Configurable;
import org.apache.openjpa.lib.conf.Configuration;
import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.util.Closeable;
import org.apache.openjpa.lib.util.ConcreteClassGenerator;
/**
@@ -38,7 +39,7 @@ import org.apache.openjpa.lib.util.Concr
* usage of Commons DBCP when available, use AutoDriverDataSource instead.
*/
public abstract class DBCPDriverDataSource
-extends SimpleDriverDataSource implements Configurable {
+extends SimpleDriverDataSource implements Configurable, Closeable {
private static String DBCPPACKAGENAME = "org.apache.commons.dbcp";
private static String DBCPBASICDATASOURCENAME =
"org.apache.commons.dbcp.BasicDataSource";
@@ -67,6 +68,20 @@ extends SimpleDriverDataSource implement
return getDBCPConnection(props);
}
+ public void close() throws SQLException {
+ try {
+ if (_ds != null) {
+ if (isDBCPLoaded()) {
+
((org.apache.commons.dbcp.BasicDataSource)_dbcpClass.cast(_ds)).close();
+ }
+ }
+ } catch (ClassCastException cce) {
+ // no-op
+ } finally {
+ _ds = null;
+ }
+ }
+
protected Connection getDBCPConnection(Properties props) throws
SQLException {
Connection con = getDBCPDataSource(props).getConnection();
if (con == null) {
Modified: openjpa/trunk/openjpa-persistence-jdbc/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/pom.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/pom.xml Wed Sep 29 21:43:11 2010
@@ -134,7 +134,6 @@
</dependency>
</dependencies>
<properties>
- <postgresql.version>8.4-701.jdbc3</postgresql.version>
<connection.driver.name>org.postgresql.Driver</connection.driver.name>
<!--<connection.url>jdbc:postgresql://localhost/openjpa</connection.url>-->
<connection.url>${openjpa.postgresql.url}</connection.url>
@@ -741,11 +740,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<scope>test</scope>
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jta/ContainerTest.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jta/ContainerTest.java?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
---
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jta/ContainerTest.java
(original)
+++
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jta/ContainerTest.java
Wed Sep 29 21:43:11 2010
@@ -68,6 +68,21 @@ public abstract class ContainerTest exte
@Override
public void tearDown() throws Exception {
+ try {
+ if (emf != null && emf.isOpen()) {
+ // can't use AbstractPersistenceTestCase.closeEMF() due to
using managed transactions
+ // closeAllOpenEMs(emf);
+ emf.close();
+ }
+ } catch (Exception e) {
+ // if a test failed, swallow any exceptions that happen
+ // during tear-down, as these just mask the original problem.
+ if (testResult.wasSuccessful()) {
+ throw e;
+ }
+ } finally {
+ emf = null;
+ }
}
protected void commit() {
Modified: openjpa/trunk/openjpa-persistence-locking/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-locking/pom.xml (original)
+++ openjpa/trunk/openjpa-persistence-locking/pom.xml Wed Sep 29 21:43:11 2010
@@ -143,7 +143,6 @@
</dependency>
</dependencies>
<properties>
- <postgresql.version>8.3-603.jdbc3</postgresql.version>
<connection.driver.name>org.postgresql.Driver</connection.driver.name>
<connection.url>${openjpa.postgresql.url}</connection.url>
<connection.username>${openjpa.postgresql.username}</connection.username>
@@ -676,16 +675,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>jakarta-regexp</groupId>
<artifactId>jakarta-regexp</artifactId>
<scope>test</scope>
Modified: openjpa/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/pom.xml?rev=1002860&r1=1002859&r2=1002860&view=diff
==============================================================================
--- openjpa/trunk/pom.xml (original)
+++ openjpa/trunk/pom.xml Wed Sep 29 21:43:11 2010
@@ -75,6 +75,7 @@
<derby.version>10.5.3.0_1</derby.version>
<hsqldb.version>1.8.0.10</hsqldb.version>
<mysql.version>5.1.12</mysql.version>
+ <postgresql.version>8.4-701.jdbc3</postgresql.version>
<!-- other common versions -->
<slf4jVersion>1.6.1</slf4jVersion>
</properties>
@@ -596,6 +597,12 @@
<version>${hsqldb.version}</version>
</dependency>
<dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>jakarta-regexp</groupId>
<artifactId>jakarta-regexp</artifactId>
<version>1.4</version>
@@ -640,15 +647,15 @@
<dependencies>
<dependency>
- <groupId>net.sourceforge.findbugs</groupId>
- <artifactId>annotations</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>