Skip to content

Conversation

@wlsh44
Copy link

@wlsh44 wlsh44 commented Dec 17, 2025

Issue

When executing the example code from the Pipelining documentation using Spring Data Redis 4.0.0, a ClassCastException is thrown while attempting to cast RedisConnection to StringRedisConnection.

Related Docs

Example code in Pipelining docs:

List<Object> results = stringRedisTemplate.executePipelined(
  new RedisCallback<Object>() {
    @Override
    public Object doInRedis(RedisConnection connection) throws DataAccessException {
      StringRedisConnection stringRedisConn = (StringRedisConnection) connection; // exception occurs
      for (int i = 0; i < batchSize; i++) {
        stringRedisConn.rPop("myqueue");
      }
      return null;
    }
  }
);

The following exception occurs at runtime:

java.lang.ClassCastException: class jdk.proxy3.$Proxy128 cannot be cast to class org.springframework.data.redis.connection.StringRedisConnection

It appears that this issue is caused by change in StringRedisTemplate.
Starting with commit 3a930ce, StringRedisTemplate no longer overrides preProcessConnection() to return a DefaultStringRedisConnection.

Fix

Fixed the example code following the same approach as the modifications applied to the testExecutePipelinedCustomSerializer() test in commit 3a930ce.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 17, 2025
Signed-off-by: wlsh44 <k87913j@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants