• ■ ■ ■ ■ ■
    commons-utils/src/main/java/io/onedev/commons/utils/command/LineConsumer.java
    skipped 65 lines
    66 66   }
    67 67   }
    68 68  
    69  - @Override
    70  - public void flush() throws IOException {
    71  - if (buffer.size() > 0)
    72  - consume(getLine());
    73  - super.flush();
    74  - }
    75  - 
    76 69   @Override
    77 70   public void close() throws IOException {
    78  - flush();
     71 + if (buffer.size() > 0)
     72 + consume(getLine());
    79 73   super.close();
    80 74   }
    81 75  
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    commons-utils/src/main/java/io/onedev/commons/utils/command/ProcessStreamPumper.java
    skipped 23 lines
    24 24  
    25 25   private final Future<?> stdinPumper;
    26 26   
    27  - private final OutputStream stdout;
    28  -
    29  - private final OutputStream stderr;
    30  -
    31 27   public ProcessStreamPumper(Process process, @Nullable OutputStream stdout,
    32 28   @Nullable OutputStream stderr, @Nullable InputStream stdin) {
    33  - this.stdout = stdout;
    34  - this.stderr = stderr;
    35  -
    36  - stdoutPumper = createPump(process.getInputStream(), stdout, true, false, false);
    37  - stderrPumper = createPump(process.getErrorStream(), stderr, true, false, false);
     29 + stdoutPumper = createPump(process.getInputStream(), stdout);
     30 + stderrPumper = createPump(process.getErrorStream(), stderr);
    38 31  
    39 32   if (stdin != null) {
    40  - stdinPumper = createPump(stdin, process.getOutputStream(), false, true, true);
     33 + stdinPumper = createPump(stdin, process.getOutputStream());
    41 34   } else {
    42 35   stdinPumper = null;
    43 36   try {
    skipped 18 lines
    62 55   stderrPumper.get();
    63 56   if (stdinPumper != null)
    64 57   stdinPumper.get();
    65  -
    66  - if (stdout != null)
    67  - stdout.flush();
    68  - if (stderr != null)
    69  - stderr.flush();
    70  - } catch (InterruptedException | ExecutionException | IOException e) {
     58 + } catch (InterruptedException | ExecutionException e) {
    71 59   throw ExceptionUtils.unchecked(e);
    72 60   }
    73 61   
    74 62   }
    75 63   
    76  - private Future<?> createPump(InputStream input, @Nullable OutputStream output,
    77  - boolean closeInputWhenExhausted, boolean closeOutputWhenExhausted, boolean flush) {
     64 + private Future<?> createPump(InputStream input, @Nullable OutputStream output) {
    78 65  
    79 66   return EXECUTOR.submit(new Runnable() {
    80 67   
    skipped 5 lines
    86 73   while ((length = input.read(buf)) > 0) {
    87 74   if (output != null) {
    88 75   output.write(buf, 0, length);
    89  - if (flush)
    90  - output.flush();
     76 + output.flush();
    91 77   }
    92 78   }
    93 79   } catch (IOException e) {
    skipped 3 lines
    97 83   while (input.read(buf) > 0);
    98 84   } catch (IOException e) {
    99 85   }
    100  - if (closeInputWhenExhausted) {
    101  - try {
    102  - input.close();
    103  - } catch (IOException e) {
    104  - }
    105  - }
    106  - if (output != null && closeOutputWhenExhausted) {
     86 + try {
     87 + input.close();
     88 + } catch (IOException e) {
     89 + }
     90 + if (output != null) {
    107 91   try {
    108 92   output.close();
    109 93   } catch (IOException e) {
    skipped 10 lines
Please wait...
Page is in error, reload to recover