Skip to content

Topic/ggivo/cae 2680 redis server stub for push notifications - #4487

Open
ggivo wants to merge 56 commits into
feature/sch-1from
topic/ggivo/CAE-2680-redis-server-stub-for-push-notifications
Open

Topic/ggivo/cae 2680 redis server stub for push notifications#4487
ggivo wants to merge 56 commits into
feature/sch-1from
topic/ggivo/CAE-2680-redis-server-stub-for-push-notifications

Conversation

@ggivo

@ggivo ggivo commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Moderate risk because it replaces the custom test server infrastructure and rewrites several timing-sensitive tests; failures are likely to surface as flaky/changed test behavior even though production code is largely untouched.

Overview
Introduces a new in-test RESP3 RedisServerStub (with an in-memory datastore, command registry, push injection, and a pub/sub manager) and removes the previous redis.clients.jedis.util.server.TcpMockServer/RespResponse/CommandHandler utilities.

Updates existing mock-based tests (ConnectionMockTest, CacheConnectionMockTest, UnifiedJedisProactiveRebindTest, ConnectionAdaptiveTimeoutTest) to use RedisServerStub and explicit MaintenanceEvent push messages; the adaptive-timeout test is reworked to use a command interceptor + async blocking to simulate blocking behavior.

Adds new RedisClient pub/sub test suite: a shared RedisClientPubSubTestBase, a real-server integration test (RedisClientPubSubIT) for RESP2/RESP3, and a RESP3-only mock test (RedisClientPubSubMockTest) plus PubSubTestHelper. Also expands the formatter plugin includes to cover new server and pubsub test packages.

Reviewed by Cursor Bugbot for commit 9b790db. Bugbot is set up for automated code reviews on this repo. Configure here.

ggivo added 30 commits March 24, 2026 10:22
   - Preparation step for processing custom push notifications
   - Push notification can appear out-of band in-between executed commands
   - Current Connection implementation does not support out of band Push notifications
   - Meaning it will crash if "CLIENT TRACKING ON is enabled" on regular Jedis Connection and "invalidation" push event is triggered

 This commit provides a way to register push handler for the connection which process incoming push messages, before actual command is executed.  To preserve backward compatibility unprocessed push messages are forward to application logic as before.

   - By default Connection will start with NOOP push handler which marks any incoming push event as processed and skips it
   - On subcsribe/psubscribe a dedicated push handler is registered which propagates to the app only supported push  vents such as (message, subscribe, unsubscribe ...)
   - CacheConection is refactored to use a push handler handling "invalidate" push events only, and skipping any other

# Conflicts:
#	src/main/java/redis/clients/jedis/Connection.java
#	src/test/java/redis/clients/jedis/commands/jedis/PublishSubscribeCommandsTest.java
This commit adds a new PushHandlerChain class that implements the Chain of
Responsibility pattern for Redis RESP3 push message handling. Key features:

- Allows composing multiple PushHandlers in a processing chain
- Push events propagate through the complete chain in sequence
- Events marked as not processed are propagated to the client application
- Provides both constructor-based and fluent builder API for chain creation
- Includes predefined handlers for common use cases (CONSUME_ALL, PROPAGATE_ALL)
- Supports immutable chain transformations via methods like then(),

The chain approach provides a flexible way to handle different types of push
messages (invalidations, pub/sub, etc.) with specialized handlers while
maintaining a clean separation of concerns.

Example usage:
  PushHandlerChain chain = PushHandlerChain.of(loggingHandler)
      .then(invalidationHandler)
      .then(PushHandlerChain.PROPAGATE_PUB_SUB_PUSH_HANDLER);
  - code clean up
  - added relaxed timeout configuration
  - fix unit tests
Register PushInvalidateConsumer after cache is initialised
ConenctionFactory should be rebound before triggering the disposal of Idle connection, so that any newly creaetd are using the proper hostname
Issue : If Maintenace notifications are received during blocking command, relaxTimeout is enforced instead of infinit timeout.

Fix: Introduce dedicated relax timeout setting for blocking commands. It will fall back to infinit timeout if not set
   - Mark all pushes by default as processed
   - Remove CONSUME_ALL_HANDLER
 - Use existing ReflectionTestUtil instead of ReflectionTestUtils.java
 - address connection pool now uses builder - socketFactory not accessible
 - test should now use Endpoints
 - ListenerNotificationConsumer from Jedis
        moved to Connection
 - fix PushMessageNotificationTest
 - fix pom.xml missing includes tag
 - ConnectionTestHelper is obsolete after rebase
 - fix A MIGRATING event on connection A triggers AdaptiveTimeoutHandler for all connections
ggivo added 12 commits April 2, 2026 12:15
  - redis-stub-server core infrastructure and command framework files

# Conflicts:
#	src/test/java/redis/clients/jedis/upgrade/ConnectionAdaptiveTimeoutTest.java
#	src/test/java/redis/clients/jedis/util/server/TcpMockServer.java
 - prepare infra to run basic pub/sub tests agains RedisServerStub
 - add pub/sub tests against RedisServerStub verifying arbitrary push messages are handled
@github-actions

github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown

Test Results

  177 files  +1    177 suites  +1   10m 50s ⏱️ -30s
8 535 tests +8  7 666 ✅  - 650  869 💤 +658  0 ❌ ±0 
3 228 runs   - 5  2 940 ✅  - 230  288 💤 +225  0 ❌ ±0 

Results for commit 9b790db. ± Comparison against base commit 28a4814.

♻️ This comment has been updated with latest results.

@jit-ci

jit-ci Bot commented Apr 14, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Comment thread src/test/java/redis/server/stub/ClientHandler.java
Comment thread src/test/java/redis/server/stub/CommandContext.java
Comment thread src/test/java/redis/server/stub/command/server/HelloCommand.java
Comment thread src/test/java/redis/server/stub/command/server/ClientCommand.java
Comment thread src/test/java/redis/clients/jedis/upgrade/ConnectionAdaptiveTimeoutTest.java Outdated
Comment thread src/test/java/redis/server/stub/TcpMockServer.java
Comment thread src/test/java/redis/server/stub/RedisServerStub.java Outdated
Comment thread src/test/java/redis/server/stub/RedisServerStub.java

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9b790db. Configure here.

"Socket timeout should be relaxed blocking timeout during blocking command");
// await command to be executed
Awaitility.await().atMost(Duration.ofSeconds(100))
.until(() -> connection.isRelaxedTimeoutActive());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaitility timeout vastly exceeds JUnit test timeout

Low Severity

The test has @Timeout(value = 1, unit = TimeUnit.SECONDS) but both Awaitility.await().atMost(Duration.ofSeconds(100)) calls use a 100-second max wait. Awaitility's timeout can never trigger because JUnit kills the test at 1 second first, producing a generic timeout error instead of Awaitility's descriptive condition-not-met failure. The 100 likely should be 1 or the @Timeout value needs increasing.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9b790db. Configure here.

Base automatically changed from feature/hu-notifications-rebased-wo-generic-push-listeners to feature/sch-1 July 9, 2026 13:39
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