Skip to content

Commit 7401331

Browse files
committed
Add termination.
1 parent aba46ef commit 7401331

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/sdk/server/src/main/java/com/launchdarkly/sdk/server/PollingSynchronizerImpl.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ public PollingSynchronizerImpl(
3939
private void doPoll() {
4040
try {
4141
FDv2SourceResult res = poll(selectorSource.getSelector(), true).get();
42+
switch(res.getResultType()) {
43+
case CHANGE_SET:
44+
break;
45+
case STATUS:
46+
switch(res.getStatus().getState()) {
47+
case INTERRUPTED:
48+
break;
49+
case SHUTDOWN:
50+
// The base poller doesn't emit shutdown, we instead handle it at this level.
51+
// So when shutdown is called, we return shutdown on subsequent calls to next.
52+
break;
53+
case TERMINAL_ERROR:
54+
case GOODBYE:
55+
synchronized (this) {
56+
task.cancel(true);
57+
}
58+
internalShutdown();
59+
break;
60+
}
61+
break;
62+
}
4263
resultQueue.put(res);
4364
} catch (InterruptedException | ExecutionException e) {
4465
// TODO: Determine if handling is needed.

0 commit comments

Comments
 (0)