Repository navigation
Description
Is this a support request?
No. It is a bug in the FDv2 data source code, with a reproduction against a local server.
Describe the bug
With the FDv2 data system (dataSystem(Components.dataSystem().defaultMode())), a 401 can stop the data source for good.
When every synchronizer backs off after an error (for example a 401), FDv2DataSource sets the status to INTERRUPTED with a null error. The data source outage tracker is on by default (logDataSourceOutageAsErrorAfter = 1 minute), and it calls recordError(null). recordError calls newError.getKind() and throws a NullPointerException. The catch block in the data source loop logs the exception and closes the source manager, so the data source thread ends. No synchronizer starts again: the client keeps its last data and never reconnects, also after the 401 ends.
In our test cluster, three running clients got this exception during a 401 and made no further data source request for 8 hours, until we restarted them.
Code path (tag launchdarkly-java-server-sdk-7.19.1, unchanged on main at 943a9fd):
FDv2DataSource.java:734:dataSourceUpdates.updateStatus(DataSourceStatusProvider.State.INTERRUPTED, null);DataSourceUpdatesImpl.java:316-326: for State.INTERRUPTED,trackDataSourceStatecallsrecordError(newError)with the null error.DataSourceUpdatesImpl.java:342:new ErrorInfo(newError.getKind(), newError.getStatusCode(), null, null)throws.FDv2DataSource.java:544-549: the exception ends the data source loop.
A possible fix: skip a null error in recordError (or in trackDataSourceState), or pass the last synchronizer error instead of null at FDv2DataSource.java:734.
To reproduce
A local server that answers 401 to every request (srv401.py):
import http.server, sys, datetime
class H(http.server.BaseHTTPRequestHandler):
def _r(self):
print(datetime.datetime.now().isoformat(), self.command, self.path, flush=True)
b = b'{"code":"unauthorized","message":"Invalid account ID or API key"}'
self.send_response(401); self.send_header('Content-Type', 'application/json')
self.send_header('Content-Length', str(len(b))); self.end_headers(); self.wfile.write(b)
do_GET = _r; do_POST = _r; do_REPORT = _r
def log_message(self, *a): pass
http.server.ThreadingHTTPServer(('127.0.0.1', int(sys.argv[1])), H).serve_forever()A client with the FDv2 data system and the default logging configuration (Park401.java):
import com.launchdarkly.sdk.server.*;
import java.time.*;
public class Park401 {
public static void main(String[] a) throws Exception {
String base = "http://127.0.0.1:" + a[0];
LDConfig cfg = new LDConfig.Builder()
.serviceEndpoints(Components.serviceEndpoints().streaming(base).polling(base).events(base))
.startWait(Duration.ofSeconds(2))
.events(Components.noEvents())
.dataSystem(Components.dataSystem().defaultMode())
.build();
LDClient c = new LDClient("sdk-00000000-0000-0000-0000-000000000000", cfg);
Thread.sleep(Long.parseLong(a[1]) * 1000);
System.exit(0);
}
}- Start the server:
python3 srv401.py 18080. - Compile and run the client for 6 minutes:
javac -cp launchdarkly-java-server-sdk-7.19.1.jar Park401.java && java -cp launchdarkly-java-server-sdk-7.19.1.jar:. Park401 18080 360.
Result on 7.19.0 and on 7.19.1: the client sends 3 requests (poll, stream, poll) in the first 2 s. Both synchronizers back off after the 401, and the NullPointerException below is logged. The server receives no request after that for the rest of the 6 minutes.
Expected behavior
The data source retries when the first synchronizer backoff ends. With .logging(Components.logging().logDataSourceOutageAsErrorAfter(null)) added to the same client, there is no exception, and the synchronizers retry after their backoff (after 157 s on 7.19.1 and 223 s on 7.19.0 in our runs). We use this setting as a workaround. It turns off the "has not been established within 1 minute" error log.
Logs
[com.launchdarkly.sdk.server.LDClient.DataSource] WARN: Synchronizer 'StreamingSynchronizer(V2)' is backing off for 263s after an unexpected error (ERROR_RESPONSE(401)@2026-12-01T16:37:44.411412Z).
[com.launchdarkly.sdk.server.LDClient.DataSource] WARN: Synchronizer 'PollingSynchronizer(V2)' is backing off for 228s after an unexpected error (ERROR_RESPONSE(401)@2026-12-01T16:37:45.018812Z).
[com.launchdarkly.sdk.server.LDClient.DataSource] WARN: All synchronizers are backing off for at least 227s.
[com.launchdarkly.sdk.server.LDClient.DataSource] ERROR: Unexpected error in data source: java.lang.NullPointerException: Cannot invoke "com.launchdarkly.sdk.server.interfaces.DataSourceStatusProvider$ErrorInfo.getKind()" because "newError" is null
SDK version
7.19.0 and 7.19.1. The code is unchanged on main (943a9fd).
Language version, developer tools
OpenJDK 21 (our clients) and OpenJDK 25 (the reproduction above).
OS/platform
Linux containers (distroless Java 21) for our clients. macOS 26.5 on arm64 for the reproduction.
Additional context
SDK 7.11.0 does not have this code path. We found the bug while we tested how SDK versions behave during LaunchDarkly outages and 401 responses.
Activity
tanderson-ld commentedon Dec 1, 2026
Hi @pulkits15 , thank you for reporting this. Digging in now.
tanderson-ld commentedon Dec 1, 2026
Release is in progress.
tanderson-ld commentedon Dec 1, 2026
Fixed should be available in 7.19.2 . Please re-open if you don't feel this was resolved. Thank you!