Skip to content

Commit 4e7aa3a

Browse files
author
Ajay Kannan
committed
try continue to consuming output in the event of exception
1 parent 007a9ab commit 4e7aa3a

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ private static Path executablePath(String cmd) {
179179
}
180180

181181
private static class ProcessStreamReader extends Thread {
182-
private volatile BufferedReader reader;
183-
private boolean terminated = false;
182+
private final BufferedReader reader;
183+
private volatile boolean terminated = false;
184184

185185
ProcessStreamReader(InputStream inputStream) {
186186
super("Local GCD InputStream reader");
@@ -195,15 +195,15 @@ void terminate() throws IOException {
195195

196196
@Override
197197
public void run() {
198-
try {
199-
while (!terminated) {
198+
while (!terminated) {
199+
try {
200200
String line = reader.readLine();
201201
if (line == null) {
202202
terminated = true;
203203
}
204+
} catch (IOException e) {
205+
// ignore
204206
}
205-
} catch (IOException e) {
206-
// ignore
207207
}
208208
}
209209

@@ -219,11 +219,11 @@ private static class ProcessErrorStreamReader extends Thread {
219219
private static final String GCD_LOGGING_CLASS =
220220
"com.google.apphosting.client.serviceapp.BaseApiServlet";
221221

222-
private volatile BufferedReader errorReader;
222+
private final BufferedReader errorReader;
223223
private String currentLog = null;
224224
private Level currentLogLevel = null;
225225
private boolean collectionMode = false;
226-
private boolean terminated = false;
226+
private volatile boolean terminated = false;
227227

228228
ProcessErrorStreamReader(InputStream errorStream, String blockUntil) throws IOException {
229229
super("Local GCD ErrorStream reader");
@@ -245,10 +245,10 @@ void terminate() throws IOException {
245245

246246
@Override
247247
public void run() {
248-
try {
249-
String previousLine = "";
250-
String nextLine = "";
251-
while (!terminated) {
248+
String previousLine = "";
249+
String nextLine = "";
250+
while (!terminated) {
251+
try {
252252
previousLine = nextLine;
253253
nextLine = errorReader.readLine();
254254
if (nextLine == null) {
@@ -257,9 +257,9 @@ public void run() {
257257
} else {
258258
processLogLine(previousLine, nextLine);
259259
}
260+
} catch (IOException e) {
261+
// ignore
260262
}
261-
} catch (IOException e) {
262-
// ignore
263263
}
264264
}
265265

0 commit comments

Comments
 (0)