mirror of
https://github.com/sbt/sbt.git
synced 2026-09-01 10:37:54 +02:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user