Skip to content

Commit 304f253

Browse files
egahlinshipilev
authored andcommitted
8362836: JFR: Broken pipe in jdk/jfr/event/io/TestIOTopFrame.java
Backport-of: 1b94a3466e7bb3815c0caeeeebff6018b6440455
1 parent 8149318 commit 304f253

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/jdk/jdk/jfr/event/io/TestIOTopFrame.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.Map;
5353
import java.util.TreeMap;
5454
import java.util.concurrent.Callable;
55+
import java.util.concurrent.CountDownLatch;
5556
import java.util.concurrent.ExecutorService;
5657
import java.util.concurrent.Executors;
5758

@@ -246,22 +247,25 @@ private static void testSocketChannels() throws Exception {
246247
r.enable(EVENT_SOCKET_READ).withStackTrace();
247248
r.enable(EVENT_SOCKET_WRITE).withStackTrace();
248249
r.start();
249-
Thread readerThread = Thread.ofPlatform().start(() -> readSocketChannel(ssc));
250+
CountDownLatch latch = new CountDownLatch(1);
251+
Thread readerThread = Thread.ofPlatform().start(() -> readSocketChannel(ssc, latch));
250252
writeSocketChannel(ssc);
253+
latch.countDown();
251254
readerThread.join();
252255
r.stop();
253256
assertTopFrames(r, "readSocket", 6, "readSocketChannel", 2, "writeSocket", 3, "writeSocketChannel", 2);
254257
}
255258
}
256259
}
257260

258-
private static void readSocketChannel(ServerSocketChannel ssc) {
261+
private static void readSocketChannel(ServerSocketChannel ssc, CountDownLatch latch) {
259262
ByteBuffer[] buffers = createBuffers();
260263
try (SocketChannel sc = ssc.accept()) {
261264
sc.read(buffers[0]); // 1
262265
sc.read(buffers); // 2
263266
try (InputStream is = sc.socket().getInputStream()) {
264267
readSocket(is);
268+
latch.await();
265269
}
266270
} catch (Exception ioe) {
267271
throw new RuntimeException(ioe);

0 commit comments

Comments
 (0)