Skip to content

Commit

Permalink
Fix #1430 by detecting case when client connect/disconnects before me…
Browse files Browse the repository at this point in the history
…trics start getting emitted
  • Loading branch information
mattrjacobs committed Dec 14, 2016
1 parent 9263593 commit 62d9c30
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,17 @@ public void onNext(String sampleDataAsString) {
while (moreDataWillBeSent.get() && !isDestroyed) {
try {
Thread.sleep(pausePollerThreadDelayInMs);
//in case stream has not started emitting yet, catch any clients which connect/disconnect before emits start
writer.print("ping: \n\n");
// explicitly check for client disconnect - PrintWriter does not throw exceptions
if (writer.checkError()) {
throw new IOException("io error");
}
writer.flush();
} catch (InterruptedException e) {
moreDataWillBeSent.set(false);
} catch (IOException ioe) {
moreDataWillBeSent.set(false);
}
}
}
Expand Down

0 comments on commit 62d9c30

Please sign in to comment.