mirror of https://github.com/sbt/sbt.git
Flush ObjectOutputStreams after construction
This protects against deadlocks between the writing and reading end, since the ObjectOutputStream constructor writes a header, but does not flush, and the ObjectInputStream constructor reads the header, and blocks until it's read.
This commit is contained in:
parent
259bb192cf
commit
b337f3d9ac
|
|
@ -49,6 +49,8 @@ private[sbt] object ForkTests
|
|||
case _: java.net.SocketException => return
|
||||
}
|
||||
val os = new ObjectOutputStream(socket.getOutputStream)
|
||||
// Must flush the header that the constructor writes, otherwise the ObjectInputStream on the other end may block indefinitely
|
||||
os.flush()
|
||||
val is = new ObjectInputStream(socket.getInputStream)
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ public class ForkMain {
|
|||
Socket socket = new Socket(InetAddress.getByName(null), Integer.valueOf(args[0]));
|
||||
final ObjectInputStream is = new ObjectInputStream(socket.getInputStream());
|
||||
final ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream());
|
||||
// Must flush the header that the constructor writes, otherwise the ObjectInputStream on the other end may block indefinitely
|
||||
os.flush();
|
||||
try {
|
||||
try {
|
||||
new Run().run(is, os);
|
||||
|
|
|
|||
Loading…
Reference in New Issue