Skip to content

Commit 4d8d986

Browse files
author
Ajay Kannan
committed
Avoid reading extra output during local gcd shutdown.
1 parent 71ac555 commit 4d8d986

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ private static void extractFile(ZipInputStream zipIn, File filePath) throws IOEx
526526

527527
public static boolean sendQuitRequest(int port) {
528528
StringBuilder result = new StringBuilder();
529+
String shutdownMsg = "Shutting down local server";
529530
try {
530531
URL url = new URL("http", "localhost", port, "/_ah/admin/quit");
531532
HttpURLConnection con = (HttpURLConnection) url.openConnection();
@@ -537,13 +538,13 @@ public static boolean sendQuitRequest(int port) {
537538
out.flush();
538539
InputStream in = con.getInputStream();
539540
int currByte = 0;
540-
while ((currByte = in.read()) != -1) {
541+
while ((currByte = in.read()) != -1 && result.length() < shutdownMsg.length()) {
541542
result.append(((char) currByte));
542543
}
543544
} catch (IOException ignore) {
544545
// ignore
545546
}
546-
return result.toString().startsWith("Shutting down local server");
547+
return result.toString().startsWith(shutdownMsg);
547548
}
548549

549550
public void stop() throws IOException, InterruptedException {

0 commit comments

Comments
 (0)