Skip to content

Commit

Permalink
Merge pull request Netflix#1444 from mattrjacobs/optimize-server-thre…
Browse files Browse the repository at this point in the history
…ad-exit

Optimize server thread exit
  • Loading branch information
mattrjacobs authored Dec 14, 2016
2 parents 11ca011 + 58962fe commit b43069b
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,12 @@ public void onError(Throwable e) {
@Override
public void onNext(String sampleDataAsString) {
if (sampleDataAsString != null) {
try {
writer.print("data: " + sampleDataAsString + "\n\n");
// explicitly check for client disconnect - PrintWriter does not throw exceptions
if (writer.checkError()) {
throw new IOException("io error");
}
writer.flush();
} catch (IOException ioe) {
writer.print("data: " + sampleDataAsString + "\n\n");
// explicitly check for client disconnect - PrintWriter does not throw exceptions
if (writer.checkError()) {
moreDataWillBeSent.set(false);
}
writer.flush();
}
}
});
Expand All @@ -167,13 +163,11 @@ public void onNext(String sampleDataAsString) {
writer.print("ping: \n\n");
// explicitly check for client disconnect - PrintWriter does not throw exceptions
if (writer.checkError()) {
throw new IOException("io error");
moreDataWillBeSent.set(false);
}
writer.flush();
} catch (InterruptedException e) {
moreDataWillBeSent.set(false);
} catch (IOException ioe) {
moreDataWillBeSent.set(false);
}
}
}
Expand Down

0 comments on commit b43069b

Please sign in to comment.