Updated Branches:
  refs/heads/develop 727bd6e52 -> 2bc2987d9

minor bug fixes to avoid access to a connection pool that has been shutdown


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/2bc2987d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/2bc2987d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/2bc2987d

Branch: refs/heads/develop
Commit: 2bc2987d90370e495b10945c4f2a849978a4325e
Parents: 727bd6e
Author: Sebastian Schaffert <[email protected]>
Authored: Thu May 16 17:56:14 2013 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Thu May 16 17:56:14 2013 +0200

----------------------------------------------------------------------
 .../marmotta/kiwi/persistence/KiWiPersistence.java |   29 ++++++++++-----
 1 files changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/2bc2987d/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
index 27927f3..5760efa 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
@@ -125,8 +125,8 @@ public class KiWiPersistence {
         // interceptors
         poolConfig.setJdbcInterceptors(
                 "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"   +
-                "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;" +
-                "org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport"
+                        
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;" +
+                        
"org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport"
         );
 
         if(log.isDebugEnabled()) {
@@ -291,7 +291,11 @@ public class KiWiPersistence {
      * @throws SQLException in case a new connection could not be established
      */
     public KiWiConnection getConnection() throws SQLException {
-        return new KiWiConnection(this,dialect,cacheManager);
+        if(connectionPool != null) {
+            return new KiWiConnection(this,dialect,cacheManager);
+        } else {
+            throw new SQLException("connection pool is closed, database 
connections not available");
+        }
     }
 
     /**
@@ -300,18 +304,21 @@ public class KiWiPersistence {
      * @throws SQLException
      */
     public Connection getJDBCConnection() throws SQLException {
-        Connection conn = connectionPool.getConnection();
-        conn.setAutoCommit(false);
-        //conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
-
-        //managedConnections.add(conn);
+        if(connectionPool != null) {
+            Connection conn = connectionPool.getConnection();
+            conn.setAutoCommit(false);
 
-        return conn;
+            return conn;
+        } else {
+            throw new SQLException("connection pool is closed, database 
connections not available");
+        }
     }
 
 
     private void forceCloseConnections() {
-        connectionPool.close(true);
+        if(connectionPool != null) {
+            connectionPool.close(true);
+        }
 
         connectionPool = new DataSource(poolConfig);
     }
@@ -397,6 +404,8 @@ public class KiWiPersistence {
         garbageCollector.shutdown();
         cacheManager.shutdown();
         connectionPool.close();
+
+        connectionPool = null;
     }
 
     /**

Reply via email to