Skip to content
Permalink
Browse files

0003989: Java versions 11 and 12 should work with SymmetricDS

  • Loading branch information...
philipmarzullo64 committed Jun 6, 2019
1 parent 718ecc5 commit c036f3d4d83225c765710e4debcd3e557f1b66f7
Showing with 71 additions and 119 deletions.
  1. +14 −6 symmetric-assemble/common.gradle
  2. +4 −3 symmetric-client/src/main/java/org/jumpmind/symmetric/ClientSymmetricEngine.java
  3. +2 −5 symmetric-client/src/main/java/org/jumpmind/symmetric/ext/MsSqlBulkDataLoaderFactory.java
  4. +2 −5 symmetric-client/src/main/java/org/jumpmind/symmetric/ext/MySqlBulkDataLoaderFactory.java
  5. +1 −6 symmetric-client/src/main/java/org/jumpmind/symmetric/ext/PostgresBulkDataLoaderFactory.java
  6. +1 −4 symmetric-client/src/main/java/org/jumpmind/symmetric/io/MsSqlBulkDatabaseWriter.java
  7. +1 −4 symmetric-client/src/main/java/org/jumpmind/symmetric/io/MySqlBulkDatabaseWriter.java
  8. +2 −7 symmetric-client/src/main/java/org/jumpmind/symmetric/io/PostgresBulkDatabaseWriter.java
  9. +3 −11 symmetric-client/src/test/java/org/jumpmind/symmetric/io/OracleBulkDatabaseWriterTest.java
  10. +3 −6 symmetric-client/src/test/java/org/jumpmind/symmetric/io/PostgresBulkDatabaseWriterTest.java
  11. +6 −4 ...etric-client/src/test/java/org/jumpmind/symmetric/io/data/writer/MsSqlBulkDatabaseWriterTest.java
  12. +4 −4 ...etric-client/src/test/java/org/jumpmind/symmetric/io/data/writer/MySqlBulkDatabaseWriterTest.java
  13. +4 −4 ...ic-client/src/test/java/org/jumpmind/symmetric/io/data/writer/PostgresBulkDatabaseWriterTest.java
  14. +1 −0 symmetric-jdbc/build.gradle
  15. +2 −3 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/ase/AseDatabasePlatform.java
  16. +4 −4 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/ase/AseJdbcSqlTemplate.java
  17. +1 −5 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/oracle/OracleLobHandler.java
  18. +3 −3 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/sqlanywhere/SqlAnywhereDatabasePlatform.java
  19. +3 −3 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/sqlanywhere/SqlAnywhereJdbcSqlTemplate.java
  20. +10 −12 symmetric-jdbc/src/main/java/org/jumpmind/db/platform/sybase/SybaseJdbcSqlTemplate.java
  21. +0 −20 symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcUtils.java
@@ -74,6 +74,14 @@ subprojects { subproject ->
sourceCompatibility=1.8
targetCompatibility=1.8

compileJava {
options.compilerArgs += '-Xlint:deprecation'
}

compileTestJava {
options.compilerArgs += '-Xlint:deprecation'
}

eclipse {
classpath {
downloadSources = true
@@ -188,11 +196,11 @@ subprojects { subproject ->
junitVersion = '4.11'
log4jVersion = '1.2.17'
slf4jVersion = '1.7.26'
mockitoVersion = '1.9.5'
powerMockVersion = '1.5.3'
mockitoVersion = '2.27.0'
powerMockVersion = '2.0.2'
mysqlVersion = '5.1.45'
servletVersion = '3.1.0'
springVersion = '4.3.22.RELEASE'
springVersion = '5.1.7.RELEASE'
jtdsVersion = '1.3.1'
voltDbVersion = '8.4.1'
bouncyCastleVersion = '1.59'
@@ -216,7 +224,7 @@ subprojects { subproject ->
provided "mysql:mysql-connector-java:$mysqlVersion"
provided ("org.mariadb.jdbc:mariadb-java-client:$mariaDbVersion") { exclude group: 'net.java.dev.jna' }
provided "org.postgresql:postgresql:$postgresqlVersion"
provided "jdbc:ojdbc:11.2.0.3"
provided "jdbc:ojdbc8:18.3.0.0"
provided "net.sourceforge.jtds:jtds:$jtdsVersion"
provided "org.voltdb:voltdbclient:$voltDbVersion"
provided "org.hsqldb:hsqldb:$hsqldbVersion"
@@ -254,8 +262,8 @@ subprojects { subproject ->
testCompile fileTree(dir: System.getProperty("user.home") + '/.symmetricds/lib', include: '*.jar')
testCompile "junit:junit:$junitVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
testCompile "org.powermock:powermock-api-mockito:$powerMockVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.powermock:powermock-api-mockito2:$powerMockVersion"
testCompile "org.powermock:powermock-module-junit4:$powerMockVersion"

deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.StringReader;
import java.lang.reflect.Constructor;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -228,7 +229,7 @@ protected void init() {
DocumentBuilder builder = factory.newDocumentBuilder();
// the "parse" method also validates XML, will throw an exception if misformatted
builder.parse(new InputSource(new StringReader(xml)));
FileUtils.write(file, xml, false);
FileUtils.write(file, xml, Charset.defaultCharset(), false);
extensionLocations.add("file:" + file.getAbsolutePath());
} catch (Exception e) {
log.error("Invalid " + ParameterConstants.EXTENSIONS_XML + " parameter.");
@@ -455,7 +456,7 @@ protected static ITypedPropertiesFactory createTypedPropertiesFactory(File propF
ITypedPropertiesFactory factory = null;
if (propFactoryClassName != null) {
try {
factory = (ITypedPropertiesFactory) Class.forName(propFactoryClassName).newInstance();
factory = (ITypedPropertiesFactory) Class.forName(propFactoryClassName).getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -471,7 +472,7 @@ public synchronized void destroy() {
super.destroy();
if (springContext instanceof AbstractApplicationContext) {
try {
((AbstractApplicationContext)springContext).destroy();
((AbstractApplicationContext)springContext).close();
} catch (Exception ex) {
}
}
@@ -25,7 +25,6 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.JdbcUtils;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
@@ -39,15 +38,12 @@
import org.jumpmind.symmetric.io.stage.IStagingManager;
import org.jumpmind.symmetric.load.AbstractDataLoaderFactory;
import org.jumpmind.symmetric.load.IDataLoaderFactory;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class MsSqlBulkDataLoaderFactory extends AbstractDataLoaderFactory implements IDataLoaderFactory {

private NativeJdbcExtractor jdbcExtractor;
private IStagingManager stagingManager;

public MsSqlBulkDataLoaderFactory(ISymmetricEngine engine) {
this.jdbcExtractor = JdbcUtils.getNativeJdbcExtractory();
this.stagingManager = engine.getStagingManager();
this.parameterService = engine.getParameterService();
}
@@ -70,7 +66,8 @@ public IDataWriter getDataWriter(String sourceNodeId, ISymmetricDialect symmetri
"||"));

return new MsSqlBulkDatabaseWriter(symmetricDialect.getPlatform(), symmetricDialect.getTargetPlatform(), symmetricDialect.getTablePrefix(),
stagingManager, jdbcExtractor, maxRowsBeforeFlush,
stagingManager,
maxRowsBeforeFlush,
fireTriggers, uncPath, fieldTerminator, rowTerminator, buildParameterDatabaseWritterSettings());
}

@@ -24,7 +24,6 @@

import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.JdbcUtils;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
@@ -38,16 +37,13 @@
import org.jumpmind.symmetric.io.stage.IStagingManager;
import org.jumpmind.symmetric.load.AbstractDataLoaderFactory;
import org.jumpmind.symmetric.load.IDataLoaderFactory;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class MySqlBulkDataLoaderFactory extends AbstractDataLoaderFactory implements IDataLoaderFactory {

private IStagingManager stagingManager;
private NativeJdbcExtractor jdbcExtractor;

public MySqlBulkDataLoaderFactory(ISymmetricEngine engine) {
this.stagingManager = engine.getStagingManager();
this.jdbcExtractor = JdbcUtils.getNativeJdbcExtractory();
this.parameterService = engine.getParameterService();
}

@@ -66,7 +62,8 @@ public IDataWriter getDataWriter(String sourceNodeId, ISymmetricDialect symmetri
boolean isReplace = Boolean.parseBoolean(parameterService.getString(ParameterConstants.MYSQL_BULK_LOAD_REPLACE, "false"));

return new MySqlBulkDatabaseWriter(symmetricDialect.getPlatform(), symmetricDialect.getTargetPlatform(), symmetricDialect.getTablePrefix(),
stagingManager, jdbcExtractor, maxRowsBeforeFlush,
stagingManager,
maxRowsBeforeFlush,
maxBytesBeforeFlush, isLocal, isReplace, buildParameterDatabaseWritterSettings());
}

@@ -24,7 +24,6 @@

import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.JdbcUtils;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.io.PostgresBulkDatabaseWriter;
@@ -35,15 +34,11 @@
import org.jumpmind.symmetric.io.data.writer.ResolvedData;
import org.jumpmind.symmetric.io.data.writer.TransformWriter;
import org.jumpmind.symmetric.load.DefaultDataLoaderFactory;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class PostgresBulkDataLoaderFactory extends DefaultDataLoaderFactory {

private NativeJdbcExtractor jdbcExtractor;

public PostgresBulkDataLoaderFactory(ISymmetricEngine engine) {
super(engine.getParameterService());
this.jdbcExtractor = JdbcUtils.getNativeJdbcExtractory();
}

public String getTypeName() {
@@ -59,7 +54,7 @@ public IDataWriter getDataWriter(String sourceNodeId, ISymmetricDialect symmetri

return new PostgresBulkDatabaseWriter(symmetricDialect.getPlatform(), symmetricDialect.getTargetPlatform(),
symmetricDialect.getTablePrefix(),
buildDatabaseWriterSettings(filters, errorHandlers, conflictSettings, resolvedData), jdbcExtractor,
buildDatabaseWriterSettings(filters, errorHandlers, conflictSettings, resolvedData),
maxRowsBeforeFlush);
}

@@ -43,11 +43,9 @@
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.jumpmind.symmetric.io.stage.IStagedResource;
import org.jumpmind.symmetric.io.stage.IStagingManager;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class MsSqlBulkDatabaseWriter extends AbstractBulkDatabaseWriter {

protected NativeJdbcExtractor jdbcExtractor;
protected int maxRowsBeforeFlush;
protected IStagingManager stagingManager;
protected IStagedResource stagedInputFile;
@@ -63,11 +61,10 @@

public MsSqlBulkDatabaseWriter(IDatabasePlatform symmetricPlatform,
IDatabasePlatform tar, String tablePrefix,
IStagingManager stagingManager, NativeJdbcExtractor jdbcExtractor,
IStagingManager stagingManager,
int maxRowsBeforeFlush, boolean fireTriggers, String uncPath, String fieldTerminator, String rowTerminator,
DatabaseWriterSettings writerSettings) {
super(symmetricPlatform, tar, tablePrefix, writerSettings);
this.jdbcExtractor = jdbcExtractor;
this.maxRowsBeforeFlush = maxRowsBeforeFlush;
this.stagingManager = stagingManager;
this.fireTriggers = fireTriggers;
@@ -47,12 +47,10 @@
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.jumpmind.symmetric.io.stage.IStagedResource;
import org.jumpmind.symmetric.io.stage.IStagingManager;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class MySqlBulkDatabaseWriter extends AbstractBulkDatabaseWriter {


protected NativeJdbcExtractor jdbcExtractor;
protected int maxRowsBeforeFlush;
protected long maxBytesBeforeFlush;
protected boolean isLocal;
@@ -67,10 +65,9 @@

public MySqlBulkDatabaseWriter(IDatabasePlatform symmetricPlatform,
IDatabasePlatform targetPlatform, String tablePrefix,
IStagingManager stagingManager, NativeJdbcExtractor jdbcExtractor,
IStagingManager stagingManager,
int maxRowsBeforeFlush, long maxBytesBeforeFlush, boolean isLocal, boolean isReplace, DatabaseWriterSettings settings) {
super(symmetricPlatform, targetPlatform, tablePrefix, settings);
this.jdbcExtractor = jdbcExtractor;
this.maxRowsBeforeFlush = maxRowsBeforeFlush;
this.maxBytesBeforeFlush = maxBytesBeforeFlush;
this.isLocal = isLocal;
@@ -39,18 +39,14 @@
import org.jumpmind.symmetric.io.data.CsvUtils;
import org.jumpmind.symmetric.io.data.DataContext;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.io.data.IDataWriter;
import org.jumpmind.symmetric.io.data.writer.DataWriterStatisticConstants;
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.postgresql.copy.CopyIn;
import org.postgresql.copy.CopyManager;
import org.postgresql.core.BaseConnection;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

public class PostgresBulkDatabaseWriter extends AbstractBulkDatabaseWriter {

protected NativeJdbcExtractor jdbcExtractor;

protected int maxRowsBeforeFlush;

protected CopyManager copyManager;
@@ -63,9 +59,8 @@

public PostgresBulkDatabaseWriter(IDatabasePlatform symmetricPlatform,
IDatabasePlatform targetPlatform, String tablePrefix, DatabaseWriterSettings settings,
NativeJdbcExtractor jdbcExtractor, int maxRowsBeforeFlush) {
int maxRowsBeforeFlush) {
super(symmetricPlatform, targetPlatform, tablePrefix, settings);
this.jdbcExtractor = jdbcExtractor;
this.maxRowsBeforeFlush = maxRowsBeforeFlush;
}

@@ -159,7 +154,7 @@ public void open(DataContext context) {
super.open(context);
try {
JdbcSqlTransaction jdbcTransaction = (JdbcSqlTransaction) getTargetTransaction();
Connection conn = jdbcExtractor.getNativeConnection(jdbcTransaction.getConnection());
Connection conn = jdbcTransaction.getConnection().unwrap(org.postgresql.jdbc.PgConnection.class);
copyManager = new CopyManager((BaseConnection) conn);
} catch (Exception ex) {
throw getPlatform().getSqlTemplate().translate(ex);
@@ -43,8 +43,6 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

import oracle.sql.TIMESTAMPLTZ;
import oracle.sql.TIMESTAMPTZ;
@@ -118,8 +116,6 @@ public void testInsert1000Rows() {
public void testInsertTimestampTZ_timestamp() throws Exception {
if (platform != null && platform instanceof OracleDatabasePlatform) {

NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();

platform.getSqlTemplate().update("truncate table test_bulkload_table_1");

List<CsvData> datas = new ArrayList<CsvData>();
@@ -139,7 +135,7 @@ public void testInsertTimestampTZ_timestamp() throws Exception {
Map<String, Object> rowData = queryForRow(id);
DataSource datasource = (DataSource)platform.getDataSource();
Connection connection = datasource.getConnection();
Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
Connection oracleConnection = connection.unwrap(oracle.jdbc.driver.OracleConnection.class);

final String[] EXPECTED_TIMESTAMPTZ = {"2007-01-02 03:20:10.0 -5:00","2007-01-02 03:20:10.0 -4:00"};

@@ -156,8 +152,6 @@ public void testInsertTimestampTZ_timestamp() throws Exception {
public void testInsertTimestampTZ_timestampWithTimeZone() throws Exception {
if (platform != null && platform instanceof OracleDatabasePlatform) {

NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();

platform.getSqlTemplate().update("truncate table test_bulkload_table_1");

List<CsvData> datas = new ArrayList<CsvData>();
@@ -177,7 +171,7 @@ public void testInsertTimestampTZ_timestampWithTimeZone() throws Exception {
Map<String, Object> rowData = queryForRow(id);
DataSource datasource = (DataSource)platform.getDataSource();
Connection connection = datasource.getConnection();
Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
Connection oracleConnection = connection.unwrap(oracle.jdbc.driver.OracleConnection.class);

checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, "2007-01-02 03:20:10.0 -8:00");
checkTimestampTZ(rowData.get("TIMESTAMPTZ3_VALUE"), oracleConnection, "2007-01-02 03:20:10.123 -8:00");
@@ -192,8 +186,6 @@ public void testInsertTimestampTZ_timestampWithTimeZone() throws Exception {
public void testInsertTimestampTZ_timestampWithLocalTimeZone() throws Exception {
if (platform != null && platform instanceof OracleDatabasePlatform) {

NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();

platform.getSqlTemplate().update("truncate table test_bulkload_table_1");

List<CsvData> datas = new ArrayList<CsvData>();
@@ -213,7 +205,7 @@ public void testInsertTimestampTZ_timestampWithLocalTimeZone() throws Exception
Map<String, Object> rowData = queryForRow(id);
DataSource datasource = (DataSource)platform.getDataSource();
Connection connection = datasource.getConnection();
Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
Connection oracleConnection = connection.unwrap(oracle.jdbc.driver.OracleConnection.class);

checkTimestampLTZ(rowData.get("TIMESTAMPLTZ9_VALUE"), oracleConnection, new String[]{"2007-01-02 06:20:10.123456789 America/New_York","2007-01-02 06:20:10.123456789 US/Eastern"});

@@ -23,21 +23,18 @@
import java.util.ArrayList;
import java.util.List;

import junit.framework.Assert;

import org.jumpmind.db.DbTestUtils;
import org.jumpmind.db.platform.oracle.OracleDatabasePlatform;
import org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform;
import org.jumpmind.db.util.BasicDataSourcePropertyConstants;
import org.jumpmind.symmetric.io.PostgresBulkDatabaseWriter;
import org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData;
import org.jumpmind.symmetric.io.data.CsvData;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor;

import org.junit.Assert;

public class PostgresBulkDatabaseWriterTest extends AbstractWriterTest {

@@ -60,7 +57,7 @@ public void setupTest() {
@Override
protected long writeData(TableCsvData... datas) {
return writeData(new PostgresBulkDatabaseWriter(platform, platform, "sym_", new DatabaseWriterSettings(),
new CommonsDbcpNativeJdbcExtractor(), 1000), datas);
1000), datas);
}

@Override

0 comments on commit c036f3d

Please sign in to comment.
You can’t perform that action at this time.