Skip to content

Commit

Permalink
0004880: Upgrade DBCP and Vaadin libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Mar 10, 2021
1 parent a10b8bd commit 16436f7
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 55 deletions.
2 changes: 1 addition & 1 deletion symmetric-assemble/common.gradle
Expand Up @@ -223,7 +223,7 @@ subprojects { subproject ->
bshVersion = '2.0b6'
commonsBeanUtilsVersion = '1.9.4'
commonsCliVersion = '1.4'
commonsDbcpVersion = '1.4'
commonsDbcpVersion = '2.8.0'
commonsFileuploadVersion = '1.4'
commonsIoVersion = '2.8.0'
commonsLangVersion = '3.11'
Expand Down
2 changes: 1 addition & 1 deletion symmetric-assemble/gradle.properties
Expand Up @@ -11,7 +11,7 @@ publishPort=?
publishServer=symmetricds.org
sourceforgeUser=?
sourceforgePassword=?
vaadinVersion=8.12.1
vaadinVersion=8.12.3
org.gradle.daemon=false
latestPreviousVersion=3.11.9
restAPISecret=?
Expand Up @@ -40,7 +40,7 @@
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jumpmind.db.platform.IDatabasePlatform;
Expand Down
Expand Up @@ -40,7 +40,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.jumpmind.db.platform.IDatabasePlatform;
Expand Down
Expand Up @@ -26,7 +26,7 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.h2.tools.Shell;

public class DbSqlCommand extends AbstractCommandLauncher {
Expand Down
Expand Up @@ -21,7 +21,7 @@ protected void setSqliteFunctionResult(ISqlTransaction transaction, final String
trans.executeCallback(new IConnectionCallback<Object>() {
@Override
public Object execute(Connection con) throws SQLException {
org.sqlite.SQLiteConnection unwrapped = ((org.sqlite.SQLiteConnection)((org.apache.commons.dbcp.DelegatingConnection)con).getInnermostDelegate());
org.sqlite.SQLiteConnection unwrapped = ((org.sqlite.SQLiteConnection)((org.apache.commons.dbcp2.DelegatingConnection)con).getInnermostDelegate());

org.sqlite.Function.create(unwrapped, name, new org.sqlite.Function() {
@Override
Expand Down
Expand Up @@ -32,7 +32,7 @@

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.jumpmind.extension.IBuiltInExtensionPoint;
import org.jumpmind.security.SecurityConstants;
Expand Down Expand Up @@ -259,11 +259,11 @@ public int getDatabaseConnectionsActive() {
}
}

@ManagedAttribute(description = "If a BasicDataSource, then show the number of active connections")
@ManagedAttribute(description = "If a BasicDataSource, then show the max number of total connections")
public int getDatabaseConnectionsMax() {
if (isBasicDataSource()) {
DataSource dataSource = engine.getDataSource();
return ((BasicDataSource) dataSource).getMaxActive();
return ((BasicDataSource) dataSource).getMaxTotal();
} else {
return -1;
}
Expand Down
Expand Up @@ -56,7 +56,7 @@
import javax.management.ObjectName;
import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
Expand Down Expand Up @@ -618,7 +618,7 @@ public synchronized Enumeration<Object> keys() {
BasicDataSource dbcp = (BasicDataSource) dataSource;
runtimeProperties.setProperty("connections.idle", String.valueOf(dbcp.getNumIdle()));
runtimeProperties.setProperty("connections.used", String.valueOf(dbcp.getNumActive()));
runtimeProperties.setProperty("connections.max", String.valueOf(dbcp.getMaxActive()));
runtimeProperties.setProperty("connections.max", String.valueOf(dbcp.getMaxTotal()));
}

Runtime rt = Runtime.getRuntime();
Expand Down
2 changes: 1 addition & 1 deletion symmetric-jdbc/build.gradle
Expand Up @@ -4,7 +4,7 @@ apply from: symAssembleDir + '/common.gradle'

dependencies {
compile project(":symmetric-db")
compile "commons-dbcp:commons-dbcp:$commonsDbcpVersion"
compile "org.apache.commons:commons-dbcp2:$commonsDbcpVersion"
compile "org.springframework:spring-jdbc:$springVersion"

compileOnly "com.h2database:h2:$h2Version"
Expand Down
Expand Up @@ -25,7 +25,7 @@

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.JdbcSqlTemplate;
import org.jumpmind.db.sql.SqlTemplateSettings;
Expand Down
Expand Up @@ -1731,6 +1731,7 @@ public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, L
foreignTable.getSchema(), foreignTable.getName(), keyColumns,
foreignTable.getColumns(), nullValues, null);
Object[] selectValues = selectRow.toArray(selectRow.keySet().toArray(new String[0]));
//platform.getObjectValues(BinaryEncoding.NONE, _defaultTableTypes, keyColumns);
List<Row> rows = transaction.query(selectSt.getSql(), new RowMapper(), selectValues, selectSt.getTypes());

if (rows != null) {
Expand Down
Expand Up @@ -102,9 +102,9 @@ public static ResettableBasicDataSource create(TypedProperties properties,
dataSource.setPassword(password);
dataSource.setInitialSize(properties.getInt(
BasicDataSourcePropertyConstants.DB_POOL_INITIAL_SIZE, 2));
dataSource.setMaxActive(properties.getInt(
dataSource.setMaxTotal(properties.getInt(
BasicDataSourcePropertyConstants.DB_POOL_MAX_ACTIVE, 10));
dataSource.setMaxWait(properties.getInt(BasicDataSourcePropertyConstants.DB_POOL_MAX_WAIT,
dataSource.setMaxWaitMillis(properties.getInt(BasicDataSourcePropertyConstants.DB_POOL_MAX_WAIT,
5000));
dataSource.setMaxIdle(properties.getInt(BasicDataSourcePropertyConstants.DB_POOL_MAX_IDLE,
8));
Expand Down
Expand Up @@ -22,11 +22,9 @@

import java.sql.SQLException;

import org.apache.commons.dbcp.AbandonedConfig;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.pool.KeyedObjectPoolFactory;
import javax.sql.DataSource;

import org.apache.commons.dbcp2.BasicDataSource;

/**
* A subclass of {@link BasicDataSource} which allows for a data source to be
Expand All @@ -35,49 +33,27 @@
*/
public class ResettableBasicDataSource extends BasicDataSource {

protected boolean closed;

public ResettableBasicDataSource() {
setAccessToUnderlyingConnectionAllowed(true);
}

@Override
public synchronized void close() {
try {
try {
super.close();
} catch (SQLException e) {
}
} finally {
closed = false;
closed = true;
super.close();
} catch (SQLException e) {
}

}

@Override
protected void createPoolableConnectionFactory(ConnectionFactory driverConnectionFactory,
KeyedObjectPoolFactory statementPoolFactory, AbandonedConfig configuration) throws SQLException {
PoolableConnectionFactory connectionFactory = null;
try {
connectionFactory =
new PoolableConnectionFactory(driverConnectionFactory,
connectionPool,
statementPoolFactory,
validationQuery,
validationQueryTimeout,
connectionInitSqls,
defaultReadOnly,
defaultAutoCommit,
defaultTransactionIsolation,
defaultCatalog,
configuration);
validateConnectionFactory(connectionFactory);
} catch (Exception e) {
try {
connectionPool.close();
} catch (Exception e1) {
}
throw new SQLException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e);
protected DataSource createDataSource() throws SQLException {
if (closed) {
closed = false;
super.start();
}
return super.createDataSource();
}


}
2 changes: 1 addition & 1 deletion symmetric-sqlexplorer/build.gradle
Expand Up @@ -50,7 +50,7 @@ dependencies {
compile project(":symmetric-io")

compile "org.apache.commons:commons-lang3:$commonsLangVersion"
compile "commons-dbcp:commons-dbcp:$commonsDbcpVersion"
compile "org.apache.commons:commons-dbcp2:$commonsDbcpVersion"
compile "commons-io:commons-io:$commonsIoVersion"

compile "org.springframework:spring-webmvc:$springVersion"
Expand Down
Expand Up @@ -6,7 +6,7 @@
import javax.servlet.annotation.WebServlet;
import javax.websocket.server.ServerContainer;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.atmosphere.container.JSR356AsyncSupport;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHolder;
Expand Down

0 comments on commit 16436f7

Please sign in to comment.