1 package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.OutputStream;
24 import org.apache.maven.shared.utils.cli.CommandLineException;
25 import org.apache.maven.shared.utils.cli.Commandline;
26
27
28
29
30
31
32
33
34 public class OutputStreamFlushableCommandline
35 extends Commandline
36 implements FlushReceiverProvider
37 {
38
39
40
41 private final class OutputStreamFlushReceiver
42 implements FlushReceiver
43 {
44 private final OutputStream outputStream;
45
46 private OutputStreamFlushReceiver( OutputStream outputStream )
47 {
48 this.outputStream = outputStream;
49 }
50
51 @Override
52 public void flush()
53 throws IOException
54 {
55 outputStream.flush();
56 }
57 }
58
59 private volatile FlushReceiver flushReceiver;
60
61 @Override
62 public Process execute()
63 throws CommandLineException
64 {
65 Process process = super.execute();
66
67 if ( process.getOutputStream() != null )
68 {
69 flushReceiver = new OutputStreamFlushReceiver( process.getOutputStream() );
70 }
71
72 return process;
73 }
74
75 @Override
76 public FlushReceiver getFlushReceiver()
77 {
78 return flushReceiver;
79 }
80
81 }