[DATAREDIS-1049] Exception raised when use empty string with keyspaceNotificationsConfigParameter with @EnableRedisRepositories annotation Created: 17/Oct/19  Updated: 18/Nov/19  Resolved: 30/Oct/19

Status: Closed
Project: Spring Data Redis
Component/s: Core
Affects Version/s: 2.2 GA (Moore)
Fix Version/s: 2.2.1 (Moore SR1), 2.3 M1 (Neumann)

Type: Bug Priority: Critical
Reporter: x-wing Assignee: Christoph Strobl
Resolution: Fixed Votes: 0
Labels: regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File exception.txt    
Last updater: Mark Paluch
Pull Request URL: https://github.com/spring-projects/spring-data-redis/pull/491
Sprint: Moore SR1


Running Spring-boot with redis instance on AWS with the following setup will be fine with spring-boot version 2.1.9 but it is now broken with 2.2.0 with an exception shown at the end of this message.

@EnableRedisRepositories(basePackages="com.xyz", redisTemplateRef="redisOperations", enableKeyspaceEvents=RedisKeyValueAdapter.EnableKeyspaceEvents.ON_STARTUP, keyspaceNotificationsConfigParameter="")
public class CacheConfiguration extends CachingConfigurerSupport { .. }


Further debugging shows that the exception comes from the call made to getRequiredAttribute for keyspaceNotificationsConfigParameter in RedisRepositoryConfigurationExtension

private static AbstractBeanDefinition createRedisKeyValueAdapter(RepositoryConfigurationSource configuration) { 
  return BeanDefinitionBuilder.rootBeanDefinition(RedisKeyValueAdapter.class)
     .addConstructorArgReference((String)configuration.getRequiredAttribute(“redisTemplateRef”, String.class))
    .addPropertyValue(“enableKeyspaceEvents”, configuration.getRequiredAttribute(“enableKeyspaceEvents”, EnableKeyspaceEvents.class))
    .addPropertyValue(“keyspaceNotificationsConfigParameter”, configuration.getRequiredAttribute(“keyspaceNotificationsConfigParameter”, String.class))
    .getBeanDefinition(); }
interface RepositoryConfigurationSource {
  default <T> T getRequiredAttribute(String name, Class<T> type) {
    Assert.hasText(name, “Attribute name must not be null or empty!“);
    return this.getAttribute(name, type).orElseThrow(() -> { 
      return new IllegalArgumentException(String.format(“No attribute named %s found!“, name)); 

By comparing Spring Data Commons version 2.2.0 which is used by the latest spring boot releases to the Spring Data Commons 2.1.11 used by the previous release
redisKeyValueAdapterProps.add("keyspaceNotificationsConfigParameter", attributes.getString("keyspaceNotificationsConfigParameter"));.
Definitely this is a change making this field as required and empty string is treated as null which causes the exception here.

Here is the documentation regarding the usage of empty string for this field:

Please recommend a work around or help fix this issue if this is an unintended side effect.

The reason that this empty string is required for AWS is a known subject that AWS does not allow modification of the CONFIG from application so we have to use the server configuration as we have setup with.


Comment by x-wing [ 17/Oct/19 ]

This issue was originally raised to spring boot under: https://github.com/spring-projects/spring-boot/issues/18640.


Comment by Mark Paluch [ 30/Oct/19 ]

I updated the affected version. It was Lovelace but the description says Spring Data Redis 2.2 which is Moore.

Generated at Wed Jul 15 09:29:00 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.