You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2016/03/30 16:40:25 UTC

[jira] [Updated] (DERBY-6881) Test failures with JDK 9-ea b111

     [ https://issues.apache.org/jira/browse/DERBY-6881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-6881:
--------------------------------------
    Attachment: d6881-classloader.diff

The attached patch, d6881-classloader.diff, seems to fix the problem with ClassLoaderTestSetup.

The purpose of ClassLoaderTestSetup is to make a test case run with a non-default context class loader. It is only used by one test case, in SecureServerTest to test the fix for the class loader leak in DERBY-6619. The way it does this currently, is by cloning the original context class loader, which happens to be the application class loader. As http://openjdk.java.net/jeps/261 explains, the application class loader is a URLClassLoader from Java 1.2 to Java 8, but it is some internal class in Java 9. When ClassLoaderTestSetup casts it to URLClassLoader, it consequently throws a ClassCastException with Java 9.

It turns out that the new context class loader does not need to be a clone of the original class loader for the purpose of this test. It seems to be sufficient that it is some other class loader than the system class loader in order to exercise the code path we want to test. The patch therefore changes ClassLoaderTestSetup to create an empty URLClassLoader that wraps the system class loader. This way we avoid the unreliable cast that causes problems on Java 9. SecureServerTest passes both on Java 8 and Java 9-ea b111 with this patch.

> Test failures with JDK 9-ea b111
> --------------------------------
>
>                 Key: DERBY-6881
>                 URL: https://issues.apache.org/jira/browse/DERBY-6881
>             Project: Derby
>          Issue Type: Bug
>          Components: Test
>    Affects Versions: 10.13.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: d6881-classloader.diff
>
>
> With JDK 9-ea b111 there are a number of test failures.
> Tests that use ClassLoaderTestSetup fail because the context class loader no longer is a URLClassLoader, which causes a ClassCastException in the class loader magic performed by the test setup:
> {noformat}
> java.lang.ClassCastException: jdk.internal.loader.ClassLoaders$AppClassLoader (in module: java.base) cannot be cast to java.net.URLClassLoader (in module: java.base)
> 	at org.apache.derbyTesting.junit.ClassLoaderTestSetup$1.run(ClassLoaderTestSetup.java:53)
> 	at org.apache.derbyTesting.junit.ClassLoaderTestSetup$1.run(ClassLoaderTestSetup.java:50)
> 	at java.security.AccessController.doPrivileged(java.base@9-ea/Native Method)
> 	at org.apache.derbyTesting.junit.ClassLoaderTestSetup.makeClassLoader(ClassLoaderTestSetup.java:49)
> 	at org.apache.derbyTesting.junit.ClassLoaderTestSetup.setUp(ClassLoaderTestSetup.java:64)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:20)
> 	at junit.extensions.TestSetup.run(TestSetup.java:25)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:58)
> {noformat}
> CollationTest, CollationTest2, LocalizedAttributeScriptTest and LocalizedDisplayScriptTest have failures, for example:
> {noformat}
> junit.framework.AssertionFailedError: Column value mismatch @ column 'ID', row 1:
>     Expected: >4<
>     Found:    >6<
>     ID,NAME
>     -- ----
>    [6, aacorn]
>    [4, Acorn]
>    [2, Ącorn]
>    [0, Smith]
>    [5, Śmith]
>    [1, Zebra]
>    [3, Żebra]
> 	at org.apache.derbyTesting.junit.BaseTestCase.newAssertionFailedError(BaseTestCase.java:1177)
> 	at org.apache.derbyTesting.junit.JDBC.addRsToReport(JDBC.java:1998)
> 	at org.apache.derbyTesting.junit.JDBC.assertRowInResultSet(JDBC.java:1497)
> 	at org.apache.derbyTesting.junit.JDBC.assertRowInResultSet(JDBC.java:1395)
> 	at org.apache.derbyTesting.junit.JDBC.assertFullResultSetMinion(JDBC.java:1257)
> 	at org.apache.derbyTesting.junit.JDBC.assertFullResultSet(JDBC.java:1168)
> 	at org.apache.derbyTesting.junit.JDBC.assertFullResultSet(JDBC.java:1125)
> 	at org.apache.derbyTesting.junit.JDBC.assertFullResultSet(JDBC.java:1083)
> 	at org.apache.derbyTesting.functionTests.tests.lang.CollationTest.checkLangBasedQuery(CollationTest.java:2055)
> 	at org.apache.derbyTesting.functionTests.tests.lang.CollationTest.testNorwayCollation(CollationTest.java:482)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:120)
> 	at org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:443)
> 	at org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:460)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> 	at junit.extensions.TestSetup.run(TestSetup.java:25)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> 	at junit.extensions.TestSetup.run(TestSetup.java:25)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:58)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> 	at junit.extensions.TestSetup.run(TestSetup.java:25)
> Caused by: junit.framework.AssertionFailedError: Column value mismatch @ column 'ID', row 1:
>     Expected: >4<
>     Found:    >6<
> 	at org.apache.derbyTesting.junit.JDBC.assertRowInResultSet(JDBC.java:1492)
> {noformat}
> And the stack trace deletion patterns in the Sed class seem to be missing out on some stack frames now, causing failures like this one in dblook_test and dblook_test_territory:
> {noformat}
> ********* Diff file derbyall/derbytools/dblook_test.diff
> *** Start: dblook_test jdk9-ea derbyall:derbytools 2016-03-29 14:16:38 ***
> 6511a6512
> > 	at java.io.FileInputStream.open0(java.base@9-ea/Native Method)
> Test Failed.
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)