Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-1049

Exception raised when use empty string with keyspaceNotificationsConfigParameter with @EnableRedisRepositories annotation



      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.





            • Assignee:
              cstrobl Christoph Strobl
              x-wing x-wing
              Last updater:
              Mark Paluch
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: