7170203: TEST_BUG: test/java/nio/MappedByteBuffer/Truncate.java failing intermittently
Alan Bateman
Alan.Bateman at oracle.com
Sat May 19 02:11:17 PDT 2012
A few days we fixed MappedByteBuffer.load so that it that it works even
after being compiled at runtime:
http://hg.openjdk.java.net/jdk8/tl/jdk/rev/332bebb463d1
It turns out that exposes an issue, of sorts, with one of the tests that
I did not see before pushing the change. The test truncates a file that
is mapped and then attempts to read from the mapped buffer, causing the
thread to terminate with an uncaught Error. The issue is that jtreg runs
the test in a thread group that has an uncaught exception handler and so
the uncaught error is causing the test to fail.
There are various ways to fix this, one would be change the task to
catch Error or Throwable. Another way, which I prefer, is to just set
the uncaught exception handler on the thread so that we have the
exception in the test output. Attached is the proposed patch.
-Alan.
diff --git a/test/java/nio/MappedByteBuffer/Truncate.java
b/test/java/nio/MappedByteBuffer/Truncate.java
--- a/test/java/nio/MappedByteBuffer/Truncate.java
+++ b/test/java/nio/MappedByteBuffer/Truncate.java
@@ -88,6 +88,11 @@
}
};
Thread t = new Thread(r);
+ t.setUncaughtExceptionHandler(new
Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ }
+ });
t.start();
More information about the nio-dev
mailing list