Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.3.2, 2.4.0-beta-1, 2.3.4
-
None
-
None
Description
There seems to be a bug in consumeProcessOutput that leads to the effect that the output captured in a StringBuilder is not available at the time it is accessed even after a waitFor(). The following code shows the behavior. (Tested on the listed versions.)
int cnt0 = 0; int cnt1 = 0; for (int i=0;i<10000;i++) { StringBuilder sb = new StringBuilder(); def proc = "whoami".execute(); proc.consumeProcessOutput(sb,sb); proc.waitFor(); def a = sb.readLines(); def b = sb.readLines(); def c = sb.readLines(); if( a.size() != b.size()) { print("."); cnt0++; } if( b.size() != c.size()) { print(","); cnt1++; } } println "" println cnt0 println cnt1
Example output:
,..,.,. 4 3
Adding a short sleep after waitFor "fixes" the issue. I expect the threads used to consume the output are not joined in waitFor but did not look deeper into the issue. If you need additional information, feel free to ask!
Best regards,
Manuel