Skip to content

Commit 74c697d

Browse files
fix: Guard against null scheme in RedisStoreImplBase for relative URIs (#185)
## Summary `URI.getScheme()` returns `null` for scheme-less URIs such as `//localhost:6379`. In `RedisStoreImplBase`, the TLS detection line: ```java boolean tls = builder.tls || builder.uri.getScheme().equals("rediss"); ``` called .equals() on that null, throwing an NPE at store construction time. Fixed by flipping to the null-safe form: boolean tls = builder.tls || "rediss".equals(builder.uri.getScheme()); A scheme-less URI now correctly resolves TLS to false (unless explicitly set via .tls(true)). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Single-line defensive null check with unchanged TLS semantics for valid `redis`/`rediss` URIs. > > **Overview** > **Fixes an NPE** when constructing the Redis data store from a URI with no scheme (e.g. `//localhost:6379`). > > TLS detection in `RedisStoreImplBase` used `builder.uri.getScheme().equals("rediss")`, which throws if `getScheme()` is `null`. It now uses `"rediss".equals(builder.uri.getScheme())`, so scheme-less URIs are treated as non-TLS unless `builder.tls` is set explicitly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 666069a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Todd Anderson <127344469+tanderson-ld@users.noreply.github.com>
1 parent 47c4f36 commit 74c697d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/java-server-sdk-redis-store/src/main/java/com/launchdarkly/sdk/server/integrations/RedisStoreImplBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected RedisStoreImplBase(RedisStoreBuilder<?> builder, LDLogger logger) {
2424
String username = builder.username == null ? RedisURIComponents.getUsername(builder.uri) : builder.username;
2525
String password = builder.password == null ? RedisURIComponents.getPassword(builder.uri) : builder.password;
2626
int database = builder.database == null ? RedisURIComponents.getDBIndex(builder.uri) : builder.database;
27-
boolean tls = builder.tls || builder.uri.getScheme().equals("rediss");
27+
boolean tls = builder.tls || "rediss".equals(builder.uri.getScheme());
2828

2929
String extra = tls ? " with TLS" : "";
3030
if (username != null) {

0 commit comments

Comments
 (0)