Commit 74c697d
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
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments