Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jackrabbit-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ org.apache.jackrabbit.core.version.RemoveAndAddVersionLabelXATest#testVersionLab
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public void init(PMContext context) throws Exception {

}

private DataSource getDataSource() throws Exception {
protected DataSource getDataSource() throws Exception {
if (getDataSourceName() == null || "".equals(getDataSourceName())) {
return connectionFactory.getDataSource(getDriver(), getUrl(), getUser(), getPassword());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package org.apache.jackrabbit.core.persistence.pool;

import org.apache.jackrabbit.core.persistence.PMContext;
import org.apache.jackrabbit.core.persistence.db.DatabasePersistenceManager;
import org.apache.jackrabbit.core.util.db.ConnectionFactory;
import org.apache.jackrabbit.core.util.db.ConnectionHelper;
import org.apache.jackrabbit.core.util.db.DerbyConnectionHelper;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;
Expand Down Expand Up @@ -246,6 +247,12 @@ public void init(PMContext context) throws Exception {
if (getSchemaObjectPrefix() == null) {
setSchemaObjectPrefix("");
}
try (Connection test = getDataSource().getConnection()) {
if (test.isClosed()) {
//may happen after a workspace shutdown
setConnectionFactory(new ConnectionFactory());
}
}
super.init(context);
// set properties
if (DERBY_EMBEDDED_DRIVER.equals(getDriver())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import junit.framework.TestCase;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.derby.iapi.jdbc.EngineConnection;
import org.apache.jackrabbit.core.config.ConfigurationException;
import org.apache.jackrabbit.core.config.DataSourceConfig;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void testClose() throws Exception {
}

private void assertPoolDefaults(BasicDataSource ds, String validationQuery, int maxCons) {
assertEquals(maxCons, ds.getMaxActive());
assertEquals(maxCons, ds.getMaxTotal());
assertEquals(validationQuery, ds.getValidationQuery());
assertTrue(ds.getDefaultAutoCommit());
assertFalse(ds.getTestOnBorrow());
Expand Down
6 changes: 3 additions & 3 deletions jackrabbit-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.14.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import javax.naming.NamingException;
import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.DelegatingConnection;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.DelegatingConnection;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.jackrabbit.core.config.DataSourceConfig;
import org.apache.jackrabbit.core.config.DataSourceConfig.DataSourceDefinition;
import org.apache.jackrabbit.util.Base64;
Expand Down Expand Up @@ -102,7 +102,7 @@ public void registerDataSources(DataSourceConfig dsc) throws RepositoryException
BasicDataSource bds =
getDriverDataSource(driverClass, def.getUrl(), def.getUser(), def.getPassword());
if (def.getMaxPoolSize() > 0) {
bds.setMaxActive(def.getMaxPoolSize());
bds.setMaxTotal(def.getMaxPoolSize());
}
if (def.getValidationQuery() != null && !"".equals(def.getValidationQuery().trim())) {
bds.setValidationQuery(def.getValidationQuery());
Expand Down Expand Up @@ -348,8 +348,8 @@ private BasicDataSource getDriverDataSource(
ds.setTestWhileIdle(true);
ds.setTimeBetweenEvictionRunsMillis(600000); // 10 Minutes
ds.setMinEvictableIdleTimeMillis(60000); // 1 Minute
ds.setMaxActive(-1); // unlimited
ds.setMaxIdle(GenericObjectPool.DEFAULT_MAX_IDLE + 10);
ds.setMaxTotal(-1); // unlimited
ds.setMaxIdle(GenericObjectPoolConfig.DEFAULT_MAX_IDLE + 10);
ds.setValidationQuery(guessValidationQuery(url));
ds.setAccessToUnderlyingConnectionAllowed(true);
ds.setPoolPreparedStatements(Boolean.valueOf(System.getProperty(SYSTEM_PROPERTY_POOL_PREPARED_STATEMENTS, "true")));
Expand Down