This is THE CLASSIC DEADLOCK in operation.
I can easily reproduce this if I have
in my environment.
If I have, instead,
then everything works perfectly.
The thread dump in the attached file from Manfred reveals the bug in AdminTask.java
See my comment in <common-utils> ProcessStreamDrainer.java:
- If you don't drain a process' stdout and stderr it will cause a deadlock after a few hundred bytes of output.
- At that point the Process is blocked because its stdout and/or stderr buffer is full and it is waiting for the Java caller
- to drain it. Meanwhile the Java program is blocked waiting on the external process.
- This class makes this common, but messy and tricky, procedure easier.
- It creates 2 threads that drain output on stdout and stderr of the external process.
- <p> Sample Code:
That's exactly what happens here. Here is the code from AdminTask. Notice how it does not create any threads:
File asadmin = getAsAdmin(f);
Process pr = Runtime.getRuntime().exec(asadmin.getAbsolutePath() + " " + commandExec);
BufferedReader error = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
while((errorLine=error.readLine()) != null)
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while((inputLine=input.readLine()) != null)