--- a/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java Mon May 27 22:59:18 2019 +0200
+++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java Mon May 27 23:05:54 2019 +0200
@@ -28,9 +28,9 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import jdk.jfr.Event;
import jdk.jfr.Recording;
@@ -57,21 +57,27 @@
testSetReuseFalse(p);
}
- private static void testSetReuseFalse(Path p) throws IOException {
+ private static void testSetReuseFalse(Path p) throws Exception {
+ AtomicBoolean fail = new AtomicBoolean(false);
Map<RecordedEvent, RecordedEvent> identity = new IdentityHashMap<>();
try (EventStream es = EventStream.openFile(p)) {
es.setReuse(false);
es.onEvent(e -> {
if (identity.containsKey(e)) {
+ fail.set(true);
throw new Error("Unexpected reuse!");
}
identity.put(e,e);
});
es.start();
}
+ if (fail.get()) {
+ throw new Exception("Unexpected resued");
+ }
}
- private static void testSetReuseTrue(Path p) throws IOException {
+ private static void testSetReuseTrue(Path p) throws Exception {
+ AtomicBoolean fail = new AtomicBoolean(false);
try (EventStream es = EventStream.openFile(p)) {
es.setReuse(true);
RecordedEvent[] events = new RecordedEvent[1];
@@ -80,12 +86,16 @@
events[0] = e;
} else {
if (e != events[0]) {
+ fail.set(true);
throw new Error("No reuse");
}
}
});
es.start();
}
+ if (fail.get()) {
+ throw new Exception("No reuse");
+ }
}
private static Path makeRecording() throws IOException {