From 639be6c1cdb2747e3d4a7d04ce5966d27d1f3102 Mon Sep 17 00:00:00 2001 From: ozinoviev Date: Mon, 27 Aug 2018 15:48:52 +0300 Subject: [PATCH] DRILL-6349: Drill JDBC driver fails on Java 1.9+ with NoClassDefFoundError: sun/misc/VM closes #1446 --- .../drill/common/config/DrillConfig.java | 3 +- contrib/storage-jdbc/pom.xml | 3 +- distribution/src/resources/drill-config.sh | 11 ++++ distribution/src/resources/sqlline.bat | 12 ++++ exec/java-exec/pom.xml | 20 +++---- .../drill/exec/compile/CompilationConfig.java | 2 +- .../bytecode/ReplacingInterpreter.java | 2 + .../drill/exec/expr/ClassGenerator.java | 4 +- .../FileSystemPartitionDescriptor.java | 2 +- .../drill/TestUtf8SupportInQueryString.java | 3 - .../drill/exec/fn/impl/TestCastFunctions.java | 4 -- .../drill/exec/fn/impl/TestDateFunctions.java | 3 - .../fn/impl/testing/TestDateConversions.java | 3 - .../exec/fn/interp/TestConstantFolding.java | 3 - .../TestImpersonationMetadata.java | 4 +- .../drill/exec/store/avro/AvroFormatTest.java | 4 -- .../complex/writer/TestExtendedTypes.java | 3 - .../src/test/resources/drill-udf/pom.xml | 4 +- exec/jdbc-all/pom.xml | 5 +- .../apache/drill/jdbc/ITTestShadedJar.java | 14 ++--- ...489CallsAfterCloseThrowExceptionsTest.java | 56 ++++++++++++++++++- .../drill/exec/memory/BoundsCheckingTest.java | 1 + logical/pom.xml | 1 - pom.xml | 24 ++++---- 24 files changed, 123 insertions(+), 68 deletions(-) diff --git a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java index 423d4f0e8d1..d7d7340a509 100644 --- a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java +++ b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; +import io.netty.util.internal.PlatformDependent; import org.apache.drill.common.exceptions.DrillConfigurationException; import org.apache.drill.common.exceptions.UserException; import org.apache.drill.common.scanner.ClassPathScanner; @@ -46,7 +47,7 @@ public class DrillConfig extends NestedConfig { private final ImmutableList startupArguments; @SuppressWarnings("restriction") - private static final long MAX_DIRECT_MEMORY = sun.misc.VM.maxDirectMemory(); + private static final long MAX_DIRECT_MEMORY = PlatformDependent.maxDirectMemory(); @VisibleForTesting public DrillConfig(Config config) { diff --git a/contrib/storage-jdbc/pom.xml b/contrib/storage-jdbc/pom.xml index 7de89f08afe..ad139d467ed 100755 --- a/contrib/storage-jdbc/pom.xml +++ b/contrib/storage-jdbc/pom.xml @@ -104,7 +104,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.18.1 + 2.22.0 1 @@ -115,6 +115,7 @@ **/*IT.java + false diff --git a/distribution/src/resources/drill-config.sh b/distribution/src/resources/drill-config.sh index d23788b006a..8f32a47326c 100644 --- a/distribution/src/resources/drill-config.sh +++ b/distribution/src/resources/drill-config.sh @@ -302,6 +302,17 @@ export DRILLBIT_CODE_CACHE_SIZE=${DRILLBIT_CODE_CACHE_SIZE:-"1G"} export DRILLBIT_OPTS="-Xms$DRILL_HEAP -Xmx$DRILL_HEAP -XX:MaxDirectMemorySize=$DRILL_MAX_DIRECT_MEMORY" export DRILLBIT_OPTS="$DRILLBIT_OPTS -XX:ReservedCodeCacheSize=$DRILLBIT_CODE_CACHE_SIZE -Ddrill.exec.enable-epoll=false" +# Check that java is newer than 1.8 +"$JAVA" -version 2>&1 | grep "version" | egrep -e "1\.8" > /dev/null +if [ $? -gt 0 ]; then + # Allow reflective access on Java 9+ + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/java.lang=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/sun.nio.ch=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/java.nio=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --illegal-access=permit" +fi + # Under YARN, the log directory is usually YARN-provided. Replace any # value that may have been set in drill-env.sh. diff --git a/distribution/src/resources/sqlline.bat b/distribution/src/resources/sqlline.bat index 7821efaecab..40f2771152e 100755 --- a/distribution/src/resources/sqlline.bat +++ b/distribution/src/resources/sqlline.bat @@ -205,6 +205,18 @@ set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% -Dlog.path="%DRILL_LOG_DIR%\sq SET JAVA_CMD=%JAVA_HOME%\bin\%JAVA_EXE% if "%JAVA_HOME%" == "" (set JAVA_CMD=%JAVA_EXE%) set ERROR_CODE=0 + +rem Check that java is newer than 1.8 +"%JAVA_CMD%" -version 2>&1 | findstr "1.8" > nul 2>&1 +if errorlevel 1 ( + rem allow reflective access on Java 9+ + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/java.lang=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/sun.nio.ch=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/java.nio=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --illegal-access=permit +) + set SQLLINE_CALL=sqlline.SqlLine -ac org.apache.drill.exec.client.DrillSqlLineApplication -d org.apache.drill.jdbc.Driver if NOT "test%QUERY%"=="test" ( echo %QUERY% | "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS% diff --git a/exec/java-exec/pom.xml b/exec/java-exec/pom.xml index 43897efd0d7..cbe2285f467 100644 --- a/exec/java-exec/pom.xml +++ b/exec/java-exec/pom.xml @@ -64,16 +64,15 @@ ${kerby.version} test - - - - - org.ow2.asm - asm-debug-all - 5.0.3 - + asm-commons + ${asm.version} + + + org.ow2.asm + asm-util + ${asm.version} org.apache.drill.contrib.data @@ -81,11 +80,6 @@ ${project.version} test - - - - - org.apache.commons commons-pool2 diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java index 7d7180d2c3f..62408132323 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java @@ -24,5 +24,5 @@ public class CompilationConfig { * Never use asm.Opcodes values directly in calls that require them. Use ASM_OPCODES * instead, so that we can change it here once for all references. */ - public final static int ASM_API_VERSION = Opcodes.ASM5; + public final static int ASM_API_VERSION = Opcodes.ASM7; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java index 93828c14b9a..13063c8a5de 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java @@ -19,6 +19,7 @@ import java.util.List; +import org.apache.drill.exec.compile.CompilationConfig; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; @@ -40,6 +41,7 @@ public class ReplacingInterpreter extends BasicInterpreter { private final List valueList; public ReplacingInterpreter(final String className, final List valueList) { + super(CompilationConfig.ASM_API_VERSION); this.className = className; this.valueList = valueList; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java index 5b33acfb602..969b5062bbc 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java @@ -161,7 +161,7 @@ public static MappingSet getDefaultMapping() { // from the JDK Modifier values to the JCodeModel JMod values: the // values are different. - int mods = JMod.PRIVATE + JMod.FINAL; + int mods = JMod.FINAL; if ((innerClass.getModifiers() & Modifier.STATIC) != 0) { mods += JMod.STATIC; } @@ -370,7 +370,7 @@ private boolean createNestedClass() { // all new fields will be declared in the class from innerClassGenerator if (innerClassGenerator == null) { try { - JDefinedClass innerClazz = clazz._class(JMod.PRIVATE, clazz.name() + "0"); + JDefinedClass innerClazz = clazz._class(JMod.NONE, clazz.name() + "0"); innerClassGenerator = new ClassGenerator<>(codeGenerator, mappings, sig, evaluationVisitor, innerClazz, model, optionManager); } catch (JClassAlreadyExistsException e) { throw new DrillRuntimeException(e); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java index 2d457015bb3..c38cc5a9ac9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java @@ -180,7 +180,7 @@ protected void createPartitionSublists() { // build a list of DFSDirPartitionLocation. for (final List dirs : dirToFileMap.keySet()) { - locations.add( new DFSDirPartitionLocation((String [])dirs.toArray(), dirToFileMap.get(dirs))); + locations.add( new DFSDirPartitionLocation(dirs.toArray(new String[dirs.size()]), dirToFileMap.get(dirs))); } locationSuperList = Lists.partition(locations, PartitionDescriptor.PARTITION_BATCH_SIZE); diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java index d6a02f87bd7..523b15b51eb 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java @@ -19,19 +19,16 @@ import mockit.Mock; import mockit.MockUp; -import mockit.integration.junit4.JMockit; import org.apache.calcite.util.Util; import org.apache.drill.common.exceptions.UserRemoteException; import org.apache.drill.test.BaseTestQuery; import org.junit.Test; -import org.junit.runner.RunWith; import java.nio.charset.Charset; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertThat; -@RunWith(JMockit.class) public class TestUtf8SupportInQueryString extends BaseTestQuery { @Test diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java index 7768909c874..37b260c6e61 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java @@ -38,17 +38,13 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; import org.apache.drill.shaded.guava.com.google.common.collect.Maps; -import mockit.integration.junit4.JMockit; - import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.hasItem; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestCastFunctions extends BaseTestQuery { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java index d61c729fc95..8c4bf8e12e9 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java @@ -19,7 +19,6 @@ import org.apache.drill.shaded.guava.com.google.common.base.Charsets; import org.apache.drill.shaded.guava.com.google.common.io.Files; -import mockit.integration.junit4.JMockit; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.categories.UnlikelyTest; import org.apache.drill.common.util.DrillFileUtils; @@ -37,12 +36,10 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestDateFunctions extends PopUnitTestBase { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java index e0121e6c186..363d326b4ab 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java @@ -17,7 +17,6 @@ */ package org.apache.drill.exec.fn.impl.testing; -import mockit.integration.junit4.JMockit; import org.apache.drill.test.BaseTestQuery; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.categories.UnlikelyTest; @@ -25,7 +24,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -37,7 +35,6 @@ import static org.hamcrest.CoreMatchers.startsWith; import static org.junit.Assert.assertThat; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestDateConversions extends BaseTestQuery { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java index c1fea16c3a3..879dc4b3461 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java @@ -19,19 +19,16 @@ import org.apache.drill.shaded.guava.com.google.common.base.Joiner; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; -import mockit.integration.junit4.JMockit; import org.apache.drill.PlanTestBase; import org.apache.drill.categories.SqlTest; import org.apache.drill.exec.planner.physical.PlannerSettings; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.io.File; import java.io.PrintWriter; import java.util.List; -@RunWith(JMockit.class) @Category(SqlTest.class) public class TestConstantFolding extends PlanTestBase { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java index 9acd0154505..6dc361549c1 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java @@ -280,7 +280,7 @@ public void testCreateViewInWSWithNoPermissionsForQueryUser() throws Exception { final String query = "CREATE VIEW " + viewName + " AS SELECT " + "c_custkey, c_nationkey FROM cp.`tpch/customer.parquet` ORDER BY c_custkey;"; - final String expErrorMsg = "PERMISSION ERROR: Permission denied: user=drillTestUser2, access=WRITE, inode=\"/drill_test_grp_0_755/"; + final String expErrorMsg = "PERMISSION ERROR: Permission denied: user=drillTestUser2, access=WRITE, inode=\"/drill_test_grp_0_755"; errorMsgTestHelper(query, expErrorMsg); // SHOW TABLES is expected to return no records as view creation fails above. @@ -351,7 +351,7 @@ public void testCreateTableInWSWithNoPermissionsForQueryUser() throws Exception thrown.expect(UserRemoteException.class); thrown.expectMessage(containsString("Permission denied: user=drillTestUser2, " + - "access=WRITE, inode=\"/drill_test_grp_0_755/")); + "access=WRITE, inode=\"/drill_test_grp_0_755")); test("CREATE TABLE %s AS SELECT c_custkey, c_nationkey " + "FROM cp.`tpch/customer.parquet` ORDER BY c_custkey", tableName); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java index 2b7edc93b64..8f2339b70fc 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java @@ -56,16 +56,12 @@ import org.apache.drill.test.TestBuilder; import org.junit.Assert; import org.junit.Test; -import org.junit.runner.RunWith; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; -import mockit.integration.junit4.JMockit; - /** * Unit tests for Avro record reader. */ -@RunWith(JMockit.class) public class AvroFormatTest extends BaseTestQuery { // XXX diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java index c2d3f9aa01e..bc27e880445 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java @@ -17,7 +17,6 @@ */ package org.apache.drill.exec.vector.complex.writer; -import mockit.integration.junit4.JMockit; import static org.junit.Assert.assertEquals; import java.nio.file.Files; @@ -30,9 +29,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(JMockit.class) public class TestExtendedTypes extends BaseTestQuery { @BeforeClass public static void setupTestFiles() { diff --git a/exec/java-exec/src/test/resources/drill-udf/pom.xml b/exec/java-exec/src/test/resources/drill-udf/pom.xml index 73618451b2b..931abedb207 100644 --- a/exec/java-exec/src/test/resources/drill-udf/pom.xml +++ b/exec/java-exec/src/test/resources/drill-udf/pom.xml @@ -63,12 +63,14 @@ ${include.files} + 1.8 + 1.8 org.apache.maven.plugins maven-source-plugin - 2.4 + 3.0.1 ${jar.finalName} diff --git a/exec/jdbc-all/pom.xml b/exec/jdbc-all/pom.xml index 7be43ab29bf..e0ae482b15b 100644 --- a/exec/jdbc-all/pom.xml +++ b/exec/jdbc-all/pom.xml @@ -241,7 +241,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.18.1 + 2.22.0 @@ -268,6 +268,7 @@ ${app.class.path} ${project.version} + false @@ -333,6 +334,7 @@ commons-beanutils:commons-beanutils-core:jar:* commons-beanutils:commons-beanutils:jar:* io.netty:netty-tcnative:jar:* + org.honton.chas.hocon:jackson-dataformat-hocon:* @@ -648,6 +650,7 @@ commons-io:commons-io commons-beanutils:commons-beanutils-core:jar:* commons-beanutils:commons-beanutils:jar:* + org.honton.chas.hocon:jackson-dataformat-hocon:* diff --git a/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java b/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java index 6319cb32e4d..4fed1464358 100644 --- a/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java +++ b/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java @@ -42,7 +42,7 @@ public class ITTestShadedJar { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ITTestShadedJar.class); private static DrillbitClassLoader drillbitLoader; - private static URLClassLoader rootClassLoader; + private static ClassLoader rootClassLoader; private static int userPort; @ClassRule @@ -55,7 +55,7 @@ protected void starting(Description description) { try { drillbitLoader = new DrillbitClassLoader(); drillbitLoader.loadClass("org.apache.commons.io.FileUtils"); - rootClassLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); + rootClassLoader = Thread.currentThread().getContextClassLoader(); Class clazz = drillbitLoader.loadClass("org.apache.drill.test.BaseTestQuery"); Class watcherClazz = drillbitLoader.loadClass("org.apache.drill.test.BaseDirTestWatcher"); @@ -134,10 +134,7 @@ private static URL getJdbcUrl() throws MalformedURLException { @Test public void testDatabaseVersion() throws Exception { - final URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(loader, getJdbcUrl()); + final URLClassLoader loader = URLClassLoader.newInstance(new URL[] {getJdbcUrl()}); Class clazz = loader.loadClass("org.apache.drill.jdbc.Driver"); try { @@ -155,10 +152,7 @@ public void testDatabaseVersion() throws Exception { @Test public void executeJdbcAllQuery() throws Exception { - final URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(loader, getJdbcUrl()); + final URLClassLoader loader = URLClassLoader.newInstance(new URL[] {getJdbcUrl()}); Class clazz = loader.loadClass("org.apache.drill.jdbc.Driver"); try { diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java index 303565fa839..b868cf593ff 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java @@ -41,6 +41,7 @@ import java.sql.ResultSetMetaData; import java.sql.SQLClientInfoException; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; @@ -412,6 +413,15 @@ private static class ClosedConnectionChecker super(intf, jdbcObject, STATEMENT_CLOSED_MESSAGE); } + @Override + protected boolean isOkayNonthrowingMethod(Method method) { + return + super.isOkayNonthrowingMethod(method) + // New Java 9 methods not implemented in Avatica. + || method.getName().equals("beginRequest") + || method.getName().equals("endRequest"); + } + @Override protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { final boolean result; @@ -424,6 +434,12 @@ else if (SQLClientInfoException.class == cause.getClass() || method.getName().equals("getClientInfo"))) { // Special good case--we had to use SQLClientInfoException from those. result = true; + } + else if (SQLFeatureNotSupportedException.class == cause.getClass() + && (method.getName().equals("setShardingKeyIfValid") + || method.getName().equals("setShardingKey"))) { + // New Java 9 methods not implemented in Avatica. + result = true; } else { result = false; } @@ -453,6 +469,24 @@ private static class ClosedPlainStatementChecker ClosedPlainStatementChecker(Class intf, Statement jdbcObject) { super(intf, jdbcObject, PLAIN_STATEMENT_CLOSED_MESSAGE); } + + @Override + protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { + final boolean result; + if (super.isOkaySpecialCaseException(method, cause)) { + result = true; + } else if (NullPointerException.class == cause.getClass() + && (method.getName().equals("enquoteIdentifier") + || method.getName().equals("enquoteLiteral") + || method.getName().equals("enquoteNCharLiteral") + || method.getName().equals("isSimpleIdentifier"))) { + result = true; + } else { + result = false; + } + + return result; + } } // class ClosedPlainStatementChecker @Test @@ -477,6 +511,24 @@ private static class ClosedPreparedStatementChecker PreparedStatement jdbcObject) { super(intf, jdbcObject, PREPAREDSTATEMENT_CLOSED_MESSAGE); } + + @Override + protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { + final boolean result; + if (super.isOkaySpecialCaseException(method, cause)) { + result = true; + } else if (NullPointerException.class == cause.getClass() + && (method.getName().equals("enquoteIdentifier") + || method.getName().equals("enquoteLiteral") + || method.getName().equals("enquoteNCharLiteral") + || method.getName().equals("isSimpleIdentifier"))) { + result = true; + } else { + result = false; + } + + return result; + } } // class closedPreparedStmtOfOpenConnChecker @Test @@ -587,7 +639,9 @@ protected boolean isOkayNonthrowingMethod(Method method) { || method.getName().equals("getConnection") // TODO: New Java 8 methods not implemented in Avatica. || method.getName().equals("getMaxLogicalLobSize") - || method.getName().equals("supportsRefCursors"); + || method.getName().equals("supportsRefCursors") + // New Java 9 methods not implemented in Avatica. + || method.getName().equals("supportsSharding"); } @Override diff --git a/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java b/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java index 5d2853bcc40..80212281366 100644 --- a/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java +++ b/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java @@ -46,6 +46,7 @@ private static boolean setBoundsChecking(boolean enabled) throws Exception modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); boolean old = field.getBoolean(null); + field.setAccessible(true); field.set(null, enabled); return old; } diff --git a/logical/pom.xml b/logical/pom.xml index ed9abb768e6..aa8fb067c83 100644 --- a/logical/pom.xml +++ b/logical/pom.xml @@ -105,7 +105,6 @@ maven-surefire-plugin - 2.15 false diff --git a/pom.xml b/pom.xml index d69c67993b9..0cc25279f77 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 3.5.3 2.7.1 2.5.1 - 1.39 + 1.43 1.0.13 2.18.3 2.3.2 - 2.7.1 - 1.1.3 + 2.7.4 + 2.1.0 1.0 2.3.26-incubating - 3.22.0-GA + 3.24.0-GA 0.6.6 0.9.10 1.8.2 4.0.2 + 7.0 4096 4096 @@ -492,7 +493,7 @@ [3.3.1,4) - [1.8,1.9) + [1.8,12) @@ -681,11 +682,11 @@ org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.8.0 maven-enforcer-plugin - 1.3.1 + 3.0.0-M1 org.codehaus.mojo @@ -710,7 +711,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.17 + 2.21.0 default-test @@ -722,7 +723,7 @@ org.apache.maven.surefire surefire-junit47 - 2.19.1 + 2.21.0 @@ -735,6 +736,8 @@ -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -XX:+CMSClassUnloadingEnabled -ea + -Djdk.attach.allowAttachSelf=true + -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar ${forkCount} true @@ -745,6 +748,7 @@ ${project.build.directory} ${excludedGroups} + false @@ -925,7 +929,7 @@ org.jmockit jmockit - 1.39 + ${jmockit.version} test