@@ -182,16 +182,23 @@ private static class ProcessStreamReader extends Thread {
182182
183183 private final Process process ;
184184 private final BufferedReader reader ;
185+ private final BufferedReader errorReader ;
185186
186- ProcessStreamReader (Process process , String blockUntil ) throws IOException {
187+ ProcessStreamReader (
188+ Process process , String blockUntil , boolean blockOnErrorStream ) throws IOException {
187189 super ("Local GCD InputStream reader" );
188190 setDaemon (true );
189191 this .process = process ;
190192 reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
193+ errorReader = new BufferedReader (new InputStreamReader (process .getErrorStream ()));
191194 if (!Strings .isNullOrEmpty (blockUntil )) {
192195 String line ;
193196 do {
194- line = reader .readLine ();
197+ if (blockOnErrorStream ) {
198+ line = errorReader .readLine ();
199+ } else {
200+ line = reader .readLine ();
201+ }
195202 } while (line != null && !line .contains (blockUntil ));
196203 }
197204 }
@@ -205,16 +212,31 @@ void terminate() throws InterruptedException, IOException {
205212 @ Override
206213 public void run () {
207214 try {
208- while (reader .readLine () != null ) {
209- // consume line
215+ boolean readerDone = false ;
216+ boolean errorReaderDone = false ;
217+ while (!readerDone || !errorReaderDone ) {
218+ if (!readerDone && reader .ready ()) {
219+ readerDone = reader .readLine () != null ;
220+ }
221+ if (!errorReaderDone && errorReader .ready ()) {
222+ String errorOutput = errorReader .readLine ();
223+ if (errorOutput == null ) {
224+ errorReaderDone = true ;
225+ } else {
226+ if (errorOutput .startsWith ("SEVERE" )) {
227+ System .err .println (errorOutput );
228+ }
229+ }
230+ }
210231 }
211232 } catch (IOException e ) {
212233 // ignore
213234 }
214235 }
215236
216- public static ProcessStreamReader start (Process process , String blockUntil ) throws IOException {
217- ProcessStreamReader thread = new ProcessStreamReader (process , blockUntil );
237+ public static ProcessStreamReader start (
238+ Process process , String blockUntil , boolean blockOnErrorStream ) throws IOException {
239+ ProcessStreamReader thread = new ProcessStreamReader (process , blockUntil , blockOnErrorStream );
218240 thread .start ();
219241 return thread ;
220242 }
@@ -396,9 +418,8 @@ private void startGcd(Path executablePath) throws IOException, InterruptedExcept
396418 .command (gcdAbsolutePath .toString (), "start" , "--testing" , "--allow_remote_shutdown" ,
397419 "--port=" + Integer .toString (port ), projectId )
398420 .directory (gcdPath )
399- .redirectErrorStream ()
400421 .start ();
401- processReader = ProcessStreamReader .start (startProcess , "Dev App Server is now running" );
422+ processReader = ProcessStreamReader .start (startProcess , "Dev App Server is now running" , true );
402423 }
403424
404425 private static String md5 (File gcdZipFile ) throws IOException {
0 commit comments