Skip to content

Commit b43069b

Browse files
authored
Merge pull request #1444 from mattrjacobs/optimize-server-thread-exit
Optimize server thread exit
2 parents 11ca011 + 58962fe commit b43069b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

hystrix-contrib/hystrix-metrics-event-stream/src/main/java/com/netflix/hystrix/contrib/sample/stream/HystrixSampleSseServlet.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,12 @@ public void onError(Throwable e) {
146146
@Override
147147
public void onNext(String sampleDataAsString) {
148148
if (sampleDataAsString != null) {
149-
try {
150-
writer.print("data: " + sampleDataAsString + "\n\n");
151-
// explicitly check for client disconnect - PrintWriter does not throw exceptions
152-
if (writer.checkError()) {
153-
throw new IOException("io error");
154-
}
155-
writer.flush();
156-
} catch (IOException ioe) {
149+
writer.print("data: " + sampleDataAsString + "\n\n");
150+
// explicitly check for client disconnect - PrintWriter does not throw exceptions
151+
if (writer.checkError()) {
157152
moreDataWillBeSent.set(false);
158153
}
154+
writer.flush();
159155
}
160156
}
161157
});
@@ -167,13 +163,11 @@ public void onNext(String sampleDataAsString) {
167163
writer.print("ping: \n\n");
168164
// explicitly check for client disconnect - PrintWriter does not throw exceptions
169165
if (writer.checkError()) {
170-
throw new IOException("io error");
166+
moreDataWillBeSent.set(false);
171167
}
172168
writer.flush();
173169
} catch (InterruptedException e) {
174170
moreDataWillBeSent.set(false);
175-
} catch (IOException ioe) {
176-
moreDataWillBeSent.set(false);
177171
}
178172
}
179173
}

0 commit comments

Comments
 (0)