Skip to content

Commit

Permalink
Merge pull request Netflix#1442 from mattrjacobs/fix-1430
Browse files Browse the repository at this point in the history
Fix Netflix#1430 by detecting case when client connect/disconnects before me…
  • Loading branch information
mattrjacobs authored Dec 14, 2016
2 parents 9263593 + 62d9c30 commit 11ca011
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 11ca011

Please sign in to comment.