RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v8]

Alan Bateman alanb at openjdk.java.net
Mon Feb 15 11:49:38 UTC 2021


On Sat, 13 Feb 2021 10:56:32 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

>> This fours tests pass without problems, when I run them separately.
>> 
>> ## sun/security/tools/jarsigner/TimestampCheck.java
>> ## sun/security/tools/keytool/DefaultOptions.java
>> ## sanity/client/SwingSet/src/ColorChooserDemoTest.java
>> ## sanity/client/SwingSet/src/SwingSet2DemoTest.java
>> 
>>     make test TEST="jtreg:sun/security/tools/jarsigner/TimestampCheck.java sun/security/tools/keytool/DefaultOptions.java sanity/client/SwingSet/src/SwingSet2DemoTest.java sanity/client/SwingSet/src/ColorChooserDemoTest.java"
>>     
>>     Building target 'test' in configuration 'windows-x86_64-server-release'
>>     Test selection 'jtreg:sun/security/tools/jarsigner/TimestampCheck.java sun/security/tools/keytool/DefaultOptions.java sanity/client/SwingSet/src/SwingSet2DemoTest.java sanity/client/SwingSet/src/ColorChooserDemoTest.java', will run:
>>     * jtreg:test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
>>     * jtreg:test/jdk/sun/security/tools/keytool/DefaultOptions.java
>>     * jtreg:test/jdk/sanity/client/SwingSet/src/SwingSet2DemoTest.java
>>     * jtreg:test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java
>> 
>>     Running test 'jtreg:test/jdk/sun/security/tools/jarsigner/TimestampCheck.java'
>>     Passed: sun/security/tools/jarsigner/TimestampCheck.java
>>     Test results: passed: 1
>>     Report written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-results\jtreg_test_jdk_sun_security_tools_jarsigner_TimestampCheck_java\html\report.html
>>     Results written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-support\jtreg_test_jdk_sun_security_tools_jarsigner_TimestampCheck_java
>>     Finished running test 'jtreg:test/jdk/sun/security/tools/jarsigner/TimestampCheck.java'
>>     Test report is stored in build/windows-x86_64-server-release/test-results/jtreg_test_jdk_sun_security_tools_jarsigner_TimestampCheck_java
>> 
>>     Running test 'jtreg:test/jdk/sun/security/tools/keytool/DefaultOptions.java'
>>     Passed: sun/security/tools/keytool/DefaultOptions.java
>>     Test results: passed: 1
>>     Report written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-results\jtreg_test_jdk_sun_security_tools_keytool_DefaultOptions_java\html\report.html
>>     Results written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-support\jtreg_test_jdk_sun_security_tools_keytool_DefaultOptions_java
>>     Finished running test 'jtreg:test/jdk/sun/security/tools/keytool/DefaultOptions.java'
>>     Test report is stored in build/windows-x86_64-server-release/test-results/jtreg_test_jdk_sun_security_tools_keytool_DefaultOptions_java
>> 
>>     Running test 'jtreg:test/jdk/sanity/client/SwingSet/src/SwingSet2DemoTest.java'
>>     Passed: sanity/client/SwingSet/src/SwingSet2DemoTest.java
>>     Test results: passed: 1
>>     Report written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-results\jtreg_test_jdk_sanity_client_SwingSet_src_SwingSet2DemoTest_java\html\report.html
>>     Results written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-support\jtreg_test_jdk_sanity_client_SwingSet_src_SwingSet2DemoTest_java
>>     Finished running test 'jtreg:test/jdk/sanity/client/SwingSet/src/SwingSet2DemoTest.java'
>>     Test report is stored in build/windows-x86_64-server-release/test-results/jtreg_test_jdk_sanity_client_SwingSet_src_SwingSet2DemoTest_java
>> 
>>     Running test 'jtreg:test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java'
>>     Passed: sanity/client/SwingSet/src/ColorChooserDemoTest.java
>>     Test results: passed: 1
>>     Report written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-results\jtreg_test_jdk_sanity_client_SwingSet_src_ColorChooserDemoTest_java\html\report.html
>>     Results written to F:\Projects\official_openjdk\build\windows-x86_64-server-release\test-support\jtreg_test_jdk_sanity_client_SwingSet_src_ColorChooserDemoTest_java
>>     Finished running test 'jtreg:test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java'
>>     Test report is stored in build/windows-x86_64-server-release/test-results/jtreg_test_jdk_sanity_client_SwingSet_src_ColorChooserDemoTest_java
>> 
>>     ==============================
>>     Test summary
>>     ==============================
>>        TEST                                              TOTAL  PASS  FAIL ERROR
>>        jtreg:test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
>>                                                              1     1     0     0
>>        jtreg:test/jdk/sun/security/tools/keytool/DefaultOptions.java
>>                                                              1     1     0     0
>>        jtreg:test/jdk/sanity/client/SwingSet/src/SwingSet2DemoTest.java
>>                                                              1     1     0     0
>>        jtreg:test/jdk/sanity/client/SwingSet/src/ColorChooserDemoTest.java
>>                                                              1     1     0     0
>>     ==============================
>>     TEST SUCCESS
>> 
>>     Finished building target 'test' in configuration 'windows-x86_64-server-release'
>
> ## jdk/jshell/ToolBasicTest.java
>     
>     make test TEST="jtreg:jdk/jshell/ToolBasicTest.java"
> 
>     STDOUT:
>     [TestNG] Running:
>       jdk/jshell/ToolBasicTest.java
> 
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.elideStartUpFromList(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.elideStartUpFromSave(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.test8142447(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testAddExports(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testBadClasspath(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testBadModulePath(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testBadSourceJarClasspath(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testClasspathDirectory(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testClasspathJar(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testClasspathUserHomeExpansion(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testConstrainedUpdates(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testCtrlD(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testEnvInStartUp(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testFeedbackNegative(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testFeedbackNormal(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testFeedbackSilent(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testHistoryReference(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testIndent(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testInterrupt(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testLoadingFromArgs(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testModulePath(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testModulePathUserHomeExpansion(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testOpen(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testOpenFileOverHttp(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testOpenLocalFileUrl(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testOpenResource(): failure
>     java.lang.AssertionError: user output: printf("%4.2f", Math.PI).
>      expected [3.14] but found [3,14]
>             at org.testng.Assert.fail(Assert.java:94)
>             at org.testng.Assert.failNotEquals(Assert.java:496)
>             at org.testng.Assert.assertEquals(Assert.java:125)
>             at org.testng.Assert.assertEquals(Assert.java:178)
>             at ReplToolTesting.assertOutput(ReplToolTesting.java:529)
>             at ReplToolTesting.assertCommand(ReplToolTesting.java:513)
>             at ToolBasicTest.lambda$testOpenResource$118(ToolBasicTest.java:559)
>             at ReplToolTesting$PromptedCommandOutputStream.write(ReplToolTesting.java:824)
>             at java.base/java.io.PrintStream.write(PrintStream.java:536)
>             at jdk.internal.le/jdk.internal.org.jline.terminal.impl.LineDisciplineTerminal.processOutputByte(LineDisciplineTerminal.java:253)
>             at jdk.internal.le/jdk.internal.org.jline.terminal.impl.LineDisciplineTerminal$FilteringOutputStream.write(LineDisciplineTerminal.java:294)
>             at java.base/sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:242)
>             at java.base/sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:321)
>             at java.base/sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:325)
>             at java.base/sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:159)
>             at java.base/java.io.OutputStreamWriter.flush(OutputStreamWriter.java:248)
>             at java.base/java.io.PrintWriter.flush(PrintWriter.java:396)
>             at jdk.internal.le/jdk.internal.org.jline.terminal.impl.AbstractTerminal.flush(AbstractTerminal.java:174)
>             at jdk.internal.le/jdk.internal.org.jline.utils.Display.update(Display.java:336)
>             at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3943)
>             at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3803)
>             at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:626)
>             at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:454)
>             at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.readLine(ConsoleIOContext.java:233)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.getInput(JShellTool.java:1263)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1199)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:991)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.run(JShellToolBuilder.java:240)
>             at ReplToolTesting.testRawRun(ReplToolTesting.java:313)
>             at ReplToolTesting.testRaw(ReplToolTesting.java:296)
>             at ReplToolTesting.test(ReplToolTesting.java:249)
>             at ReplToolTesting.test(ReplToolTesting.java:233)
>             at ReplToolTesting.test(ReplToolTesting.java:229)
>             at ReplToolTesting.test(ReplToolTesting.java:225)
>             at ToolBasicTest.testOpenResource(ToolBasicTest.java:555)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
>             at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>             at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>             at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
>             at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
>             at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
>             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
>             at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
>             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
>             at org.testng.TestRunner.privateRun(TestRunner.java:773)
>             at org.testng.TestRunner.run(TestRunner.java:623)
>             at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
>             at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
>             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
>             at org.testng.SuiteRunner.run(SuiteRunner.java:259)
>             at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
>             at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
>             at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
>             at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
>             at org.testng.TestNG.run(TestNG.java:1018)
>             at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
>             at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>             at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>             at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
>             at java.base/java.lang.Thread.run(Thread.java:831)
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testRedeclareVariableNoInit(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testRemoteExit(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testRerun(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testRerunIdRange(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testReset(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testSave(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testStartRetain(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testStartSave(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testStartupFileOption(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testStop(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testVarsWithNotActive(): success
>     config ReplToolTesting.setUp(): success
>     test ToolBasicTest.testWarningUnchecked(): success
> 
>     ===============================================
>     jdk/jshell/ToolBasicTest.java
>     Total tests run: 38, Failures: 1, Skips: 0
>     ===============================================
> 
>     STDERR:
>     java.io.EOFException
>             at java.base/java.io.DataInputStream.readInt(DataInputStream.java:398)
>             at java.base/java.io.ObjectInputStream$BlockDataInputStream.readInt(ObjectInputStream.java:3381)
>             at java.base/java.io.ObjectInputStream.readInt(ObjectInputStream.java:1113)
>             at jdk.jshell/jdk.jshell.execution.StreamingExecutionControl.readAndReportExecutionResult(StreamingExecutionControl.java:277)
>             at jdk.jshell/jdk.jshell.execution.StreamingExecutionControl.invoke(StreamingExecutionControl.java:99)
>             at jdk.jshell/jdk.jshell.execution.JdiDefaultExecutionControl.invoke(JdiDefaultExecutionControl.java:160)
>             at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:943)
>             at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:139)
>             at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3609)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1330)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1228)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1201)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:991)
>             at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.run(JShellToolBuilder.java:240)
>             at ReplToolTesting.testRawRun(ReplToolTesting.java:313)
>             at ReplToolTesting.testRaw(ReplToolTesting.java:296)
>             at ReplToolTesting.test(ReplToolTesting.java:249)
>             at ReplToolTesting.test(ReplToolTesting.java:233)
>             at ReplToolTesting.test(ReplToolTesting.java:229)
>             at ReplToolTesting.test(ReplToolTesting.java:225)
>             at ToolBasicTest.testRemoteExit(ToolBasicTest.java:680)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
>             at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>             at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>             at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
>             at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
>             at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
>             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
>             at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
>             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
>             at org.testng.TestRunner.privateRun(TestRunner.java:773)
>             at org.testng.TestRunner.run(TestRunner.java:623)
>             at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
>             at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
>             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
>             at org.testng.SuiteRunner.run(SuiteRunner.java:259)
>             at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
>             at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
>             at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
>             at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
>             at org.testng.TestNG.run(TestNG.java:1018)
>             at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
>             at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>             at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>             at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
>             at java.base/java.lang.Thread.run(Thread.java:831)
>     java.lang.Exception: failures: 1
>             at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:96)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>             at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
>             at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>             at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>             at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
>             at java.base/java.lang.Thread.run(Thread.java:831)
> 
>     JavaTest Message: Test threw exception: java.lang.Exception
>     JavaTest Message: shutting down test
> 
> 
>     TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.Exception: failures: 1
> 
> https://bugs.openjdk.java.net/browse/JDK-8212234 looks like there is already known bug this test.

@turbanoff Can you run the tests in the en_US locale? I suspect some of these tests can't run in all locales. Also can you check your environment to ensure the file paths for F: are consistent (I suspect you have a mix of f: and F: in the environment).

-------------

PR: https://git.openjdk.java.net/jdk/pull/1853


More information about the security-dev mailing list