You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/05/29 17:03:37 UTC
svn commit: r1682495 - in /jackrabbit/oak/branches/1.2: ./
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/
Author: reschke
Date: Fri May 29 15:03:36 2015
New Revision: 1682495
URL: http://svn.apache.org/r1682495
Log:
OAK-2930 - RDBBlob/DocumentStore: do not NPE calls after dispose() (ported to 1.2)
Modified:
jackrabbit/oak/branches/1.2/ (props changed)
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 29 15:03:36 2015
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675054-1675055,1675332,1675354,1675357,1675382,1675555,1675566,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676693,1676703,1676725,1677579,1677581,1677609,1677611,1677774,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679144,1679165,1679191,1679235,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java?rev=1682495&r1=1682494&r2=1682495&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java Fri May 29 15:03:36 2015
@@ -100,12 +100,16 @@ public class RDBBlobStore extends Cachin
}
}
}
- this.ch = null;
+ try {
+ this.ch.close();
+ } catch (IOException ex) {
+ LOG.error("closing connection handler", ex);
+ }
}
@Override
protected void finalize() {
- if (this.ch != null && this.callStack != null) {
+ if (!this.ch.isClosed() && this.callStack != null) {
LOG.debug("finalizing RDBDocumentStore that was not disposed", this.callStack);
}
}
Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java?rev=1682495&r1=1682494&r2=1682495&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBConnectionHandler.java Fri May 29 15:03:36 2015
@@ -16,6 +16,8 @@
*/
package org.apache.jackrabbit.oak.plugins.document.rdb;
+import java.io.Closeable;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -32,9 +34,10 @@ import org.slf4j.LoggerFactory;
/**
* Utility functions for connection handling.
*/
-public class RDBConnectionHandler {
+public class RDBConnectionHandler implements Closeable {
- private final DataSource ds;
+ private DataSource ds;
+ private long closedTime = 0L;
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(RDBConnectionHandler.class);
@@ -56,7 +59,7 @@ public class RDBConnectionHandler {
* Obtain a {@link Connection} suitable for read-only operations.
*/
public @Nonnull Connection getROConnection() throws SQLException {
- Connection c = this.ds.getConnection();
+ Connection c = getDataSource().getConnection();
c.setAutoCommit(false);
setReadOnly(c, true);
return c;
@@ -66,7 +69,7 @@ public class RDBConnectionHandler {
* Obtain a {@link Connection} suitable for read-write operations.
*/
public @Nonnull Connection getRWConnection() throws SQLException {
- Connection c = this.ds.getConnection();
+ Connection c = getDataSource().getConnection();
c.setAutoCommit(false);
setReadOnly(c, false);
return c;
@@ -139,6 +142,24 @@ public class RDBConnectionHandler {
return null;
}
+ public boolean isClosed() {
+ return this.ds == null;
+ }
+
+ @Override
+ public void close() throws IOException {
+ this.ds = null;
+ this.closedTime = System.currentTimeMillis();
+ }
+
+ private DataSource getDataSource() throws IllegalStateException {
+ DataSource result = this.ds;
+ if (result == null) {
+ throw new IllegalStateException("Connection handler is already closed ("
+ + (System.currentTimeMillis() - this.closedTime) + "ms ago)");
+ }
+ return result;
+ }
// workaround for broken connection wrappers
// see https://issues.apache.org/jira/browse/OAK-2918
Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1682495&r1=1682494&r2=1682495&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Fri May 29 15:03:36 2015
@@ -347,7 +347,11 @@ public class RDBDocumentStore implements
}
this.droppedTables = dropped.trim();
}
- this.ch = null;
+ try {
+ this.ch.close();
+ } catch (IOException ex) {
+ LOG.error("closing connection handler", ex);
+ }
}
@Override
@@ -911,7 +915,7 @@ public class RDBDocumentStore implements
@Override
protected void finalize() {
- if (this.ch != null && this.callStack != null) {
+ if (!this.ch.isClosed() && this.callStack != null) {
LOG.debug("finalizing RDBDocumentStore that was not disposed", this.callStack);
}
}