Skip to content

fix: Sentinel startup NPE + UTF-8 Redis key encoding (v1.8) - #14

Merged
wezell merged 1 commit into
trunkfrom
fix-sentinel-npe-and-utf8-keys
May 30, 2026
Merged

wezell merged 1 commit into
trunkfrom
fix-sentinel-npe-and-utf8-keys

Conversation

@wezell

@wezell wezell commented May 30, 2026

Copy link
Copy Markdown
Member

Two low-risk fixes from the code review.

P1-1 — NullPointerException at startup with Sentinel master set

initializeConfigParams() did sentinels.isEmpty() where sentinels is null whenever TOMCAT_REDIS_SESSION_SENTINEL_MASTER is set but TOMCAT_REDIS_SESSION_SENTINELS is not. The NPE propagates out of startInternal() as a LifecycleException, so Tomcat fails to boot. Fixed with an explicit null check:

if (null != sentinels && !sentinels.isEmpty()) {

M1 — Redis keys encoded with platform-default charset

All key operations (set/get/exists/ttl/expire) and the NULL_SESSION constant used String.getBytes() with no charset, i.e. the JVM default. Two cluster nodes with different default charsets could derive different key bytes for the same session and fail to find each other's data. Low real-world risk (session IDs are ASCII), but a latent cross-node bug. All encodings now pinned to StandardCharsets.UTF_8.

Bumps version 1.7 → 1.8.

Note: this does not make Redis Sentinel functional — the connection still ignores Sentinel config (tracked separately as P1-2). It only stops the NPE.

🤖 Generated with Claude Code

P1-1: initializeConfigParams() called sentinels.isEmpty() on a value that
is null whenever TOMCAT_REDIS_SESSION_SENTINEL_MASTER is set but
TOMCAT_REDIS_SESSION_SENTINELS is not, throwing NPE out of startInternal()
and preventing Tomcat from booting. Add an explicit null check.

M1: all Redis key operations (set/get/exists/ttl/expire) and the
NULL_SESSION sentinel encoded keys with String.getBytes() using the
platform-default charset, risking key-byte mismatches between cluster nodes
with different default charsets. Pin every encoding to StandardCharsets.UTF_8.

Bumps version 1.7 -> 1.8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Codex Autonomous Review:

  • Overall: patch is correct
  • New findings this run: 0
  • Prior unresolved Codex findings still relevant: 0
  • Active findings total: 0

I did not find a concrete regression introduced by this patch in the changed code paths. The Sentinel null check removes a startup failure, and the UTF-8 key updates remain compatible with the Jedis APIs used in this repository. The project also compiles successfully after the change.

Tip: comment with "/codex address comments" to attempt automated fixes for unresolved review threads.

@wezell
wezell merged commit e325ed8 into trunk May 30, 2026
1 check passed
@wezell
wezell deleted the fix-sentinel-npe-and-utf8-keys branch May 30, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant