Skip to content

Commit d8e4608

Browse files
committed
added handler exception
1 parent 9c1ba52 commit d8e4608

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

client/src/main/java/io/split/engine/common/SyncManagerImp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private void startPollingMode() {
110110
_pushManager.start();
111111
break;
112112
case STREAMING_OFF:
113-
_pushManager.stopWorkers();
113+
_pushManager.stop();
114114
_synchronizer.startPeriodicFetching();
115115
if (null != _pushStatusMonitorTask) {
116116
_pushStatusMonitorTask.cancel(false);

client/src/main/java/io/split/engine/sse/client/SSEClient.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private enum ConnectionState {
4040
CLOSED
4141
}
4242

43+
4344
private final static String KEEP_ALIVE_PAYLOAD = ":keepalive\n";
4445
private final static Integer CONNECT_TIMEOUT = 30000;
4546
private final static Integer SOCKET_TIMEOUT = 70000;
@@ -109,26 +110,31 @@ private void connectAndLoop(URI uri, CountDownLatch signal) {
109110
while (isOpen() && !Thread.currentThread().isInterrupted()) {
110111
try {
111112
handleMessage(readMessageAsString(reader));
112-
} catch (EOFException exc) {
113-
// This is when ably closes the connection on their end. IE: an invalid or expired token.
113+
} catch (EOFException | SocketTimeoutException exc) {
114+
// EOFException: This is when ably closes the connection on their end. IE: an invalid or expired token.
115+
// SocketTimeoutException: KeepAlive expired
116+
_log.warn(exc.getMessage());
114117
_statusCallback.apply(StatusMessage.RETRYABLE_ERROR);
115118
return;
116-
} catch (SocketTimeoutException exc) { // KeepAlive expired
117-
_statusCallback.apply(StatusMessage.RETRYABLE_ERROR);
118-
} catch (SocketException exc) { // Connection closed by us
119+
} catch (SocketException exc) {
120+
_log.warn(exc.getMessage());
121+
119122
if ("Socket closed".equals(exc.getMessage())) {
123+
// Connection closed by us
120124
_statusCallback.apply(StatusMessage.FORCED_STOP);
121125
return;
122126
}
123127

124-
throw exc; // If it's not a socket closed (caused by us), rethrow the exception
128+
// Connection closed by server
129+
_statusCallback.apply(StatusMessage.RETRYABLE_ERROR);
130+
return;
125131
}
126132
}
127133
} catch (Exception e) {
128134
_log.error(e.getMessage());
135+
129136
_statusCallback.apply(StatusMessage.NONRETRYABLE_ERROR);
130-
}
131-
finally {
137+
} finally {
132138
try {
133139
_ongoingResponse.get().close();
134140
} catch (IOException e) {

client/src/test/java/io/split/engine/common/SyncManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void onStreamingShutdown() throws InterruptedException {
7070
t.start();
7171
messsages.offer(PushManager.Status.STREAMING_OFF);
7272
Thread.sleep(500);
73-
Mockito.verify(_pushManager, Mockito.times(1)).stopWorkers();
73+
Mockito.verify(_pushManager, Mockito.times(1)).stop();
7474
t.interrupt();
7575
}
7676

0 commit comments

Comments
 (0)