Skip to content

Commit 0a77604

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 1049 b: refs/heads/master c: 5029f00 h: refs/heads/master i: 1047: bac1f3b v: v3
1 parent a569947 commit 0a77604

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
refs/heads/master: 8e595a7d5770967485ea04a6950cd91f9e0fa585
2+
refs/heads/master: 5029f0049958b844fc40fda1b8e627fa4449e04f
33
refs/heads/travis: 0fa997e2fc9c6b61b2d91e6d163655aae67d44b6
44
refs/heads/gh-pages: 5a10432ecc75f29812e33a8236c900379509fe99

trunk/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)