8154525: java/net/ServerSocket/ThreadStop.java fails intermittently with error while cleaning up threads after test
Reviewed-by: chegar
This commit is contained in:
parent
cf46ec878a
commit
e168404209
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -68,23 +68,23 @@ public class ThreadStop {
|
|||||||
thr.start();
|
thr.start();
|
||||||
|
|
||||||
// give server time to block in ServerSocket.accept()
|
// give server time to block in ServerSocket.accept()
|
||||||
Thread.currentThread().sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
||||||
// "stop" the thread
|
// "stop" the thread
|
||||||
thr.stop();
|
thr.stop();
|
||||||
|
|
||||||
// give thread time to stop
|
// give thread time to stop
|
||||||
Thread.currentThread().sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
||||||
// it's platform specific if Thread.stop interrupts the
|
// it's platform specific if Thread.stop interrupts the
|
||||||
// thread - on Linux/Windows most likely that thread is
|
// thread - on Linux/Windows most likely that thread is
|
||||||
// still in accept() so we connect to server which causes
|
// still in accept() so we connect to server which causes
|
||||||
// it to unblock and do JNI-stuff with a pending exception
|
// it to unblock and do JNI-stuff with a pending exception
|
||||||
|
|
||||||
try {
|
try (Socket s = new Socket("localhost", svr.localPort())) {
|
||||||
Socket s = new Socket("localhost", svr.localPort());
|
} catch (IOException ioe) {
|
||||||
} catch (IOException ioe) { }
|
}
|
||||||
|
thr.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user