0

I am reading the standardOutput from a Process using the common code to do it:

        Process p = Runtime.getRuntime().exec("gradlew assembleRelease", null , new File(this.workDir));            
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = null;     
        while ((line = input.readLine()) != null) {
            standardOutput.writeln(line);
        }
        input.close();

It worked perfectly until now. It stores the output into a txt file with my function standardOutput.writeln(line). Recently I updated my server to compile with gradle 2.8 and now i'm having a very serious problem. When gradle fails, input.readLine() function is being waiting for ever. I don't understand why. It is stuck at that line. I can't find any explanation. I thought that it can be because readLine is waiting for a /n to stop reading and there is a possibility that new gradle output is having some issues with this but i'm not sure if that is the problem.

How can this problem be solved?

NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

0

The solution finally was to read standard output and error output in two separated threads, the process was blocking itself trying to write in error output while reading standard output...

NullPointerException
  • 36,107
  • 79
  • 222
  • 382