]
Rob Stryker reassigned JBIDE-23904:
-----------------------------------
Assignee: Rob Stryker
StreamGobbler fails in 10% of cases
-----------------------------------
Key: JBIDE-23904
URL:
https://issues.jboss.org/browse/JBIDE-23904
Project: Tools (JBoss Tools)
Issue Type: Bug
Components: cdk
Affects Versions: 4.4.3.AM2
Reporter: Rob Stryker
Assignee: Rob Stryker
Fix For: 4.4.0.Final
The StreamGobbler implementation in CDKLaunchUtility fails in about 10% of cases. An
example standalone java class with copied code demonstrates this:
https://paste.fedoraproject.org/paste/F1QIqHhefBIXCECQPW9RuV5M1UNdIGYhyRL...
After playing with it (trying to run a command with a space in the path), I discovered it
failed in two different ways about 10% of the time. This is due to lack of
synchronization. The thread reading the stream might be asked for its results AFTER the
process has ended, but BEFORE the stream has been read completely.
Two things were needed: 1) synchronized control for extremely short calls to add a line
that's been read or check if the flow has been canceled, and 2) a delay in getting hte
final output even after the process has ended, as there may still be lines to read in the
stream.