@@ -180,7 +180,7 @@ private static Path executablePath(String cmd) {
180180
181181 private static class ProcessStreamReader extends Thread {
182182 private final BufferedReader reader ;
183- private volatile boolean terminated = false ;
183+ private volatile boolean terminated ;
184184
185185 ProcessStreamReader (InputStream inputStream ) {
186186 super ("Local GCD InputStream reader" );
@@ -220,10 +220,10 @@ private static class ProcessErrorStreamReader extends Thread {
220220 "com.google.apphosting.client.serviceapp.BaseApiServlet" ;
221221
222222 private final BufferedReader errorReader ;
223- private String currentLog = null ;
224- private Level currentLogLevel = null ;
225- private boolean collectionMode = false ;
226- private volatile boolean terminated = false ;
223+ private StringBuilder currentLog ;
224+ private Level currentLogLevel ;
225+ private boolean collectionMode ;
226+ private volatile boolean terminated ;
227227
228228 ProcessErrorStreamReader (InputStream errorStream , String blockUntil ) throws IOException {
229229 super ("Local GCD ErrorStream reader" );
@@ -268,11 +268,13 @@ private void processLogLine(String previousLine, String nextLine) {
268268 // [LEVEL]: error message
269269 // Exceptions and stack traces are included in gcd error stream, separated by a newline
270270 Level nextLogLevel = getLevel (nextLine );
271- if (previousLine . contains ( GCD_LOGGING_CLASS ) && nextLogLevel != null ) {
271+ if (nextLogLevel != null ) {
272272 writeLog (currentLogLevel , currentLog );
273- currentLog = "" ;
273+ currentLog = new StringBuilder () ;
274274 currentLogLevel = nextLogLevel ;
275- if (nextLine .startsWith ("SEVERE: " )) {
275+ if (!previousLine .contains (GCD_LOGGING_CLASS )) {
276+ collectionMode = false ;
277+ } else if (nextLine .startsWith ("SEVERE: " )) {
276278 collectionMode = false ; // don't show duplicate messages (see issue #258)
277279 } else {
278280 collectionMode = true ;
@@ -282,16 +284,17 @@ private void processLogLine(String previousLine, String nextLine) {
282284 } else if (collectionMode ) {
283285 if (currentLog .length () == 0 ) {
284286 // strip level out of the line
285- currentLog = "GCD" + previousLine .split (":" , 2 )[1 ] + System .getProperty ("line.separator" );
287+ currentLog .append (
288+ "GCD" + previousLine .split (":" , 2 )[1 ] + System .getProperty ("line.separator" ));
286289 } else {
287- currentLog += previousLine + System .getProperty ("line.separator" );
290+ currentLog . append ( previousLine + System .getProperty ("line.separator" ) );
288291 }
289292 }
290293 }
291294
292- private static void writeLog (Level level , String msg ) {
293- if (level != null && ! Strings . isNullOrEmpty ( msg ) ) {
294- log .log (level , msg .trim ());
295+ private static void writeLog (Level level , StringBuilder msg ) {
296+ if (level != null && msg != null && msg . length () != 0 ) {
297+ log .log (level , msg .toString (). trim ());
295298 }
296299 }
297300
0 commit comments