diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java index 87d7ade8e2ed..7fe3ee9b0b71 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java @@ -84,9 +84,6 @@ public class LocalGcdHelper { private static final String GCLOUD = "gcloud"; private static final Path INSTALLED_GCD_PATH; private static final String GCD_VERSION_PREFIX = "gcd-emulator "; - private static final String CONTENTION_ERROR_MESSAGE = - "com.google.apphosting.client.serviceapp.RpcException: " + - "too much contention on these datastore entities. please try again."; static { INSTALLED_GCD_PATH = installedGcdPath(); @@ -217,6 +214,7 @@ public void run() { try { boolean readerDone = false; boolean errorReaderDone = false; + String currentLog = null; while (!readerDone || !errorReaderDone) { if (!readerDone && reader.ready()) { readerDone = reader.readLine() != null; @@ -226,12 +224,7 @@ public void run() { if (errorOutput == null) { errorReaderDone = true; } else { - if (errorOutput.startsWith("INFO:") - || errorOutput.startsWith("com.google.apphosting.client.serviceapp")) { - if (!errorOutput.startsWith(CONTENTION_ERROR_MESSAGE)) { - System.err.println(errorOutput); - } - } + currentLog = processLog(errorOutput, currentLog); } } } @@ -240,6 +233,27 @@ public void run() { } } + private static boolean isNewGcdLog(String line) { + return line.contains("com.google.apphosting.client.serviceapp.BaseApiServlet") + && !line.trim().startsWith("at "); + } + + private static String processLog(String currentLine, String currentLog) { + if (isNewGcdLog(currentLine)) { + if (currentLog != null) { + log.info(currentLog.trim()); + } + return "GCD "; + } else if (currentLine.startsWith("SEVERE: ")) { + currentLog = null; // Don't show duplicate error messages from gcd.sh + } else if (currentLog != null && currentLine.startsWith("INFO: ")) { + return currentLog + currentLine.substring("INFO: ".length()) + "\n"; + } else if (currentLog != null && !currentLine.trim().startsWith("at ")) { + return currentLog + currentLine + "\n"; + } + return currentLog; + } + public static ProcessStreamReader start( Process process, String blockUntil, boolean blockOnErrorStream) throws IOException { ProcessStreamReader thread = new ProcessStreamReader(process, blockUntil, blockOnErrorStream);