Skip to content

Commit 6d7000b

Browse files
authored
chore: Log interrupted exception, address comment todo. (#131)
<!-- CURSOR_SUMMARY --> > [!NOTE] > **Low Risk** > Behavioral changes are limited to logging and minor exception-handling semantics in polling code; low risk aside from potentially changing how shutdown-related interrupts propagate. > > **Overview** > Improves polling robustness/observability by making `PollingBase.logger` `protected` for subclasses and clarifying that failures while translating a changeset are treated as *invalid data*. > > Updates `PollingSynchronizerImpl` to handle `InterruptedException` and `ExecutionException` separately, emitting debug logs and restoring the thread interrupt flag when interrupted. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5d0ff6e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 77c0a74 commit 6d7000b

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class PollingBase {
1919
private final FDv2Requestor requestor;
20-
private final LDLogger logger;
20+
protected final LDLogger logger;
2121

2222
public PollingBase(FDv2Requestor requestor, LDLogger logger) {
2323
this.requestor = requestor;
@@ -119,7 +119,8 @@ protected CompletableFuture<FDv2SourceResult> poll(Selector selector, boolean on
119119
);
120120
return FDv2SourceResult.changeSet(converted, fdv1Fallback);
121121
} catch (Exception e) {
122-
// TODO: Do we need to be more specific about the exception type here?
122+
// Whatever exception happened here means we couldn't handle the data. So we are going to
123+
// treat that as invalid data.
123124
DataSourceStatusProvider.ErrorInfo info = new DataSourceStatusProvider.ErrorInfo(
124125
DataSourceStatusProvider.ErrorKind.INVALID_DATA,
125126
0,

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ private void doPoll() {
7171
} else {
7272
resultQueue.put(res);
7373
}
74-
} catch (InterruptedException | ExecutionException e) {
75-
// TODO: Determine if handling is needed.
74+
} catch (InterruptedException e) {
75+
// This would likely be the result of a shutdown, so we are just logging this for debugging purposes.
76+
// Same with the ExecutionException below.
77+
logger.debug("Polling thread interrupted: {}", e.toString());
78+
Thread.currentThread().interrupt();
79+
}
80+
catch(ExecutionException e) {
81+
logger.debug("Polling thread execution exception: {}", e.toString());
7682
}
7783
}
7884

0 commit comments

Comments
 (0)