DBZ-1402 Support for JDK 11

This commit is contained in:
Brandon Brown 2019-09-23 13:01:44 -04:00 committed by Gunnar Morling
parent bf25aeb1de
commit a0f7f6ec6b
14 changed files with 113 additions and 38 deletions

View File

@ -19,7 +19,7 @@ sudo: required
dist: trusty dist: trusty
jdk: jdk:
- oraclejdk8 - oraclejdk11
services: services:
- docker - docker

View File

@ -246,6 +246,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.debezium</groupId> <groupId>io.debezium</groupId>

View File

@ -349,6 +349,11 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
</plugin>
</plugins> </plugins>
<resources> <resources>
<!-- Apply the properties set in the POM to the resource files --> <!-- Apply the properties set in the POM to the resource files -->
@ -433,6 +438,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe.plugin}</version>
<configuration> <configuration>
<skipTests>${skipITs}</skipTests> <skipTests>${skipITs}</skipTests>
<enableAssertions>true</enableAssertions> <enableAssertions>true</enableAssertions>

View File

@ -266,6 +266,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.debezium</groupId> <groupId>io.debezium</groupId>

View File

@ -225,6 +225,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.debezium</groupId> <groupId>io.debezium</groupId>

View File

@ -30,7 +30,7 @@ static <T> T getInstance(String className, Supplier<ClassLoader> classloaderSupp
: Configuration.class.getClassLoader(); : Configuration.class.getClassLoader();
try { try {
Class<? extends T> clazz = (Class<? extends T>) classloader.loadClass(className); Class<? extends T> clazz = (Class<? extends T>) classloader.loadClass(className);
return configuration == null ? clazz.newInstance() return configuration == null ? clazz.getDeclaredConstructor().newInstance()
: clazz.getConstructor(Configuration.class).newInstance(configuration); : clazz.getConstructor(Configuration.class).newInstance(configuration);
} }
catch (ClassNotFoundException e) { catch (ClassNotFoundException e) {

View File

@ -5,6 +5,7 @@
*/ */
package io.debezium.jdbc; package io.debezium.jdbc;
import java.lang.reflect.InvocationTargetException;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
@ -176,10 +177,10 @@ public static ConnectionFactory patternBasedFactory(String urlPattern, String dr
driverClassLoader = JdbcConnection.class.getClassLoader(); driverClassLoader = JdbcConnection.class.getClassLoader();
} }
Class<java.sql.Driver> driverClazz = (Class<java.sql.Driver>) Class.forName(driverClassName, true, driverClassLoader); Class<java.sql.Driver> driverClazz = (Class<java.sql.Driver>) Class.forName(driverClassName, true, driverClassLoader);
java.sql.Driver driver = driverClazz.newInstance(); java.sql.Driver driver = driverClazz.getDeclaredConstructor().newInstance();
conn = driver.connect(url, props); conn = driver.connect(url, props);
} }
catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new SQLException(e); throw new SQLException(e);
} }
LOGGER.debug("Connected to {} with {}", url, props); LOGGER.debug("Connected to {} with {}", url, props);

View File

@ -275,7 +275,7 @@ protected boolean matches(ColumnId id) {
protected static ColumnMapper instantiateMapper(Class<ColumnMapper> clazz, Configuration config) { protected static ColumnMapper instantiateMapper(Class<ColumnMapper> clazz, Configuration config) {
try { try {
ColumnMapper mapper = clazz.newInstance(); ColumnMapper mapper = clazz.getDeclaredConstructor().newInstance();
if (config != null) { if (config != null) {
mapper.initialize(config); mapper.initialize(config);
} }

View File

@ -5,6 +5,7 @@
*/ */
package io.debezium.junit; package io.debezium.junit;
import java.lang.reflect.InvocationTargetException;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.junit.Assert; import org.junit.Assert;
@ -27,7 +28,7 @@ public Statement apply(final Statement base, final Description description) {
return base; return base;
} }
try { try {
Supplier<Boolean> condition = conditionClass.value().newInstance(); Supplier<Boolean> condition = conditionClass.value().getDeclaredConstructor().newInstance();
return new Statement() { return new Statement() {
@Override @Override
public void evaluate() throws Throwable { public void evaluate() throws Throwable {
@ -50,7 +51,7 @@ else if (failure != null) {
} }
}; };
} }
catch (final InstantiationException | IllegalAccessException e) { catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -78,7 +78,7 @@
<!-- https://github.com/antlr/antlr4test-maven-plugin --> <!-- https://github.com/antlr/antlr4test-maven-plugin -->
<groupId>com.khubla.antlr</groupId> <groupId>com.khubla.antlr</groupId>
<artifactId>antlr4test-maven-plugin</artifactId> <artifactId>antlr4test-maven-plugin</artifactId>
<version>1.10</version> <version>1.11</version>
<configuration> <configuration>
<verbose>false</verbose> <verbose>false</verbose>
<showTree>false</showTree> <showTree>false</showTree>

View File

@ -707,7 +707,7 @@ public void run() {
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends SourceConnector> connectorClass = (Class<SourceConnector>) classLoader.loadClass(connectorClassName); Class<? extends SourceConnector> connectorClass = (Class<SourceConnector>) classLoader.loadClass(connectorClassName);
connector = connectorClass.newInstance(); connector = connectorClass.getDeclaredConstructor().newInstance();
} }
catch (Throwable t) { catch (Throwable t) {
fail("Unable to instantiate connector class '" + connectorClassName + "'", t); fail("Unable to instantiate connector class '" + connectorClassName + "'", t);
@ -720,7 +720,7 @@ public void run() {
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends OffsetBackingStore> offsetStoreClass = (Class<OffsetBackingStore>) classLoader.loadClass(offsetStoreClassName); Class<? extends OffsetBackingStore> offsetStoreClass = (Class<OffsetBackingStore>) classLoader.loadClass(offsetStoreClassName);
offsetStore = offsetStoreClass.newInstance(); offsetStore = offsetStoreClass.getDeclaredConstructor().newInstance();
} }
catch (Throwable t) { catch (Throwable t) {
fail("Unable to instantiate OffsetBackingStore class '" + offsetStoreClassName + "'", t); fail("Unable to instantiate OffsetBackingStore class '" + offsetStoreClassName + "'", t);
@ -771,7 +771,7 @@ public void raiseError(Exception e) {
Class<? extends Task> taskClass = connector.taskClass(); Class<? extends Task> taskClass = connector.taskClass();
task = null; task = null;
try { try {
task = (SourceTask) taskClass.newInstance(); task = (SourceTask) taskClass.getDeclaredConstructor().newInstance();
} }
catch (IllegalAccessException | InstantiationException t) { catch (IllegalAccessException | InstantiationException t) {
fail("Unable to instantiate connector's task class '" + taskClass.getName() + "'", t); fail("Unable to instantiate connector's task class '" + taskClass.getName() + "'", t);

View File

@ -622,7 +622,19 @@ protected TestSpecification usingSpec(String name) {
* @return the test specification; never null * @return the test specification; never null
*/ */
protected TestSpecification usingSpec(String name, String directory) { protected TestSpecification usingSpec(String name, String directory) {
return usingSpec(name, Paths.get(directory)); String version = System.getProperty("java.version");
String modulePath = "";
/**
* Java 11 seems to have issues finding the file when tests are invoked from the root directory. However, running
* the tests directory from the module directory work, so we only need to mess with the path when we are invoking
* the tests from the root.
*/
if (!version.startsWith("1.")) {
if (!Paths.get(directory).toAbsolutePath().toString().contains("debezium-embedded")) {
modulePath = "debezium-embedded/";
}
}
return usingSpec(name, Paths.get(modulePath + directory));
} }
/** /**

84
pom.xml
View File

@ -19,7 +19,7 @@
<connection>scm:git:git@github.com:debezium/debezium.git</connection> <connection>scm:git:git@github.com:debezium/debezium.git</connection>
<developerConnection>scm:git:git@github.com:debezium/debezium.git</developerConnection> <developerConnection>scm:git:git@github.com:debezium/debezium.git</developerConnection>
<url>https://github.com/debezium/debezium</url> <url>https://github.com/debezium/debezium</url>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<issueManagement> <issueManagement>
<system>jira</system> <system>jira</system>
@ -53,17 +53,18 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<release>8</release>
<!-- Kafka and it's dependencies MUST reflect what the Kafka version uses --> <!-- Kafka and it's dependencies MUST reflect what the Kafka version uses -->
<version.kafka>2.3.1</version.kafka> <version.kafka>2.3.1</version.kafka>
<version.kafka.scala>2.12</version.kafka.scala> <version.kafka.scala>2.12</version.kafka.scala>
<version.curator>2.11.0</version.curator> <version.curator>4.2.0</version.curator>
<version.zookeeper>3.4.14</version.zookeeper> <version.zookeeper>3.4.14</version.zookeeper>
<version.jackson>2.10.0</version.jackson> <version.jackson>2.10.0</version.jackson>
<version.org.slf4j>1.7.26</version.org.slf4j> <version.org.slf4j>1.7.26</version.org.slf4j>
<version.log4j>1.2.17</version.log4j> <version.log4j>1.2.17</version.log4j>
<!-- check new release version at https://github.com/confluentinc/schema-registry/releases --> <!-- check new release version at https://github.com/confluentinc/schema-registry/releases -->
<version.confluent.platform>5.1.2</version.confluent.platform> <version.confluent.platform>5.3.1</version.confluent.platform>
<!-- Databases --> <!-- Databases -->
<version.postgresql.driver>42.2.8</version.postgresql.driver> <version.postgresql.driver>42.2.8</version.postgresql.driver>
@ -78,28 +79,35 @@
<version.com.google.protobuf>3.8.0</version.com.google.protobuf> <version.com.google.protobuf>3.8.0</version.com.google.protobuf>
<!-- ANTLR --> <!-- ANTLR -->
<antlr.version>4.7</antlr.version> <antlr.version>4.7.2</antlr.version>
<!-- Testing --> <!-- Testing -->
<version.junit>4.12</version.junit> <version.junit>4.12</version.junit>
<version.fest>1.4</version.fest> <version.fest>1.4</version.fest>
<version.jmh>1.21</version.jmh> <version.jmh>1.21</version.jmh>
<version.mockito>2.13.0</version.mockito> <version.mockito>3.0.0</version.mockito>
<version.awaitility>3.1.6</version.awaitility> <version.awaitility>3.1.6</version.awaitility>
<!-- Maven Plugins --> <!-- Maven Plugins -->
<version.resources.plugin>2.7</version.resources.plugin> <version.compiler.plugin>3.8.1</version.compiler.plugin>
<version.dependency.plugin>2.10</version.dependency.plugin> <version.resources.plugin>3.1.0</version.resources.plugin>
<version.enforcer.plugin>3.0.0-M1</version.enforcer.plugin> <version.filtering.plugin>3.1.1</version.filtering.plugin>
<version.dependency.plugin>3.1.1</version.dependency.plugin>
<version.enforcer.plugin>3.0.0-M2</version.enforcer.plugin>
<version.jar.plugin>3.0.2</version.jar.plugin> <version.jar.plugin>3.0.2</version.jar.plugin>
<version.source.plugin>3.0.1</version.source.plugin> <version.source.plugin>3.1.0</version.source.plugin>
<version.assembly.plugin>2.4</version.assembly.plugin> <version.assembly.plugin>3.1.1</version.assembly.plugin>
<version.war.plugin>2.5</version.war.plugin> <version.war.plugin>2.5</version.war.plugin>
<version.google.formatter.plugin>0.3.1</version.google.formatter.plugin> <version.google.formatter.plugin>0.4</version.google.formatter.plugin>
<version.docker.maven.plugin>0.26.0</version.docker.maven.plugin> <version.docker.maven.plugin>0.31.0</version.docker.maven.plugin>
<version.staging.plugin>1.6.3</version.staging.plugin> <version.staging.plugin>1.6.8</version.staging.plugin>
<version.protoc.maven.plugin>3.8.0</version.protoc.maven.plugin> <version.protoc.maven.plugin>3.8.0</version.protoc.maven.plugin>
<version.javadoc.plugin>3.1.1</version.javadoc.plugin>
<version.code.formatter>2.8.1</version.code.formatter> <version.code.formatter>2.8.1</version.code.formatter>
<version.surefire.plugin>3.0.0-M3</version.surefire.plugin>
<version.checkstyle.plugin>3.0.0</version.checkstyle.plugin>
<version.release.plugin>2.5.3</version.release.plugin>
<version.impsort>1.2.0</version.impsort> <version.impsort>1.2.0</version.impsort>
<!-- Dockerfiles --> <!-- Dockerfiles -->
@ -108,6 +116,13 @@
<!--Skip long running tests by default--> <!--Skip long running tests by default-->
<skipLongRunningTests>true</skipLongRunningTests> <skipLongRunningTests>true</skipLongRunningTests>
<!--Configure forking for surefire plugin, jdk11 needs
different settings per
https://stackoverflow.com/questions/53437819/maven-surefire-and-jdk-11
https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/-->
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<!-- Don't skip integration tests by default --> <!-- Don't skip integration tests by default -->
<skipITs>false</skipITs> <skipITs>false</skipITs>
@ -119,16 +134,19 @@
<format.imports.goal>sort</format.imports.goal> <format.imports.goal>sort</format.imports.goal>
<!-- No debug options by default --> <!-- No debug options by default -->
<debug.argline /> <debug.argline/>
<!-- No modules options by default --> <!-- No modules options by default -->
<modules.argline /> <modules.argline/>
<!-- No test options by default --> <!-- No test options by default -->
<test.argline /> <test.argline/>
<!-- Assembly configuration --> <!-- Assembly configuration -->
<assembly.descriptor>connector-distribution</assembly.descriptor> <assembly.descriptor>connector-distribution</assembly.descriptor>
<!-- Needed for pre jdk 9 -->
<useSystemClassLoader>true</useSystemClassLoader>
</properties> </properties>
<modules> <modules>
@ -170,7 +188,7 @@
</repository> </repository>
<repository> <repository>
<id>ossrh</id> <id>ossrh</id>
<name>OSS Sonatype Nexus </name> <name>OSS Sonatype Nexus</name>
<url>https://oss.sonatype.org/content/groups/public/</url> <url>https://oss.sonatype.org/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
@ -219,7 +237,7 @@
<version>${version.kafka}</version> <version>${version.kafka}</version>
</dependency> </dependency>
<!-- Kafka --> <!-- Kafka -->
<dependency> <dependency>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${version.kafka.scala}</artifactId> <artifactId>kafka_${version.kafka.scala}</artifactId>
@ -404,6 +422,11 @@
<version>${project.version}</version> <version>${project.version}</version>
<type>test-jar</type> <type>test-jar</type>
</dependency> </dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -462,6 +485,11 @@
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>${version.resources.plugin}</version> <version>${version.resources.plugin}</version>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>${version.filtering.plugin}</version>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
@ -478,6 +506,7 @@
<version>${version.failsafe.plugin}</version> <version>${version.failsafe.plugin}</version>
<configuration> <configuration>
<argLine>${debug.argline} ${modules.argline} ${test.argline}</argLine> <argLine>${debug.argline} ${modules.argline} ${test.argline}</argLine>
<useSystemClassLoader>${useSystemClassLoader}</useSystemClassLoader>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -626,7 +655,7 @@
<configuration> <configuration>
<rules> <rules>
<requireMavenVersion> <requireMavenVersion>
<version>3.0.0</version> <version>3.0.5</version>
</requireMavenVersion> </requireMavenVersion>
</rules> </rules>
</configuration> </configuration>
@ -672,6 +701,9 @@
<!--runOrder>alphabetical</runOrder--> <!--runOrder>alphabetical</runOrder-->
<useFile>false</useFile> <useFile>false</useFile>
<enableAssertions>true</enableAssertions> <enableAssertions>true</enableAssertions>
<forkCount>${forkCount}</forkCount>
<reuseForks>${reuseForks}</reuseForks>
<useSystemClassLoader>${useSystemClassLoader}</useSystemClassLoader>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -821,12 +853,20 @@
</build> </build>
</profile> </profile>
<profile> <profile>
<id>jdk9</id> <id>jdk11</id>
<activation> <activation>
<jdk>9</jdk> <jdk>11</jdk>
</activation> </activation>
<properties> <properties>
<modules.argline>--add-modules java.xml.bind</modules.argline> <modules.argline>--add-modules java.xml.bind --illegal-access=permit</modules.argline>
<forkCount>0</forkCount>
<reuseForks>false</reuseForks>
<useSystemClassLoader>false</useSystemClassLoader>
<!-- When using this profile the following warning pops up,
[WARNING] bootstrap class path not set in conjunction with -source 8 -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<release>11</release>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>

View File

@ -18,12 +18,11 @@
<properties> <properties>
<!-- Instruct the build to use only UTF-8 encoding for source code --> <!-- Instruct the build to use only UTF-8 encoding for source code -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.enforcer.plugin>3.0.0-M1</version.enforcer.plugin> <version.enforcer.plugin>3.0.0-M2</version.enforcer.plugin>
<version.jar.plugin>3.0.2</version.jar.plugin> <version.jar.plugin>3.0.2</version.jar.plugin>
<version.source.plugin>3.0.1</version.source.plugin> <version.source.plugin>3.1.0</version.source.plugin>
<version.checkstyle.plugin>3.0.0</version.checkstyle.plugin>
</properties> </properties>
<!-- <!--
This module is referenced by Debezium's parent POM, so it needs to be built before the parent This module is referenced by Debezium's parent POM, so it needs to be built before the parent
@ -35,6 +34,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration> <configuration>
<showDeprecation>false</showDeprecation> <showDeprecation>false</showDeprecation>
<showWarnings>false</showWarnings> <showWarnings>false</showWarnings>
@ -43,6 +43,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>${version.checkstyle.plugin}</version>
</plugin> </plugin>
<!-- <!--
This is not deployed into a Maven repository. It is merely installed into the local Maven repository This is not deployed into a Maven repository. It is merely installed into the local Maven repository
@ -55,6 +56,17 @@
<skip>true</skip> <skip>true</skip>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<requireMavenVersion>
<version>3.0.5</version>
</requireMavenVersion>
</rules>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>