Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-16030

WildFly Infinispan subsystem CustomStoreServiceConfiguration to use modules configuration attribute as a List of modules

    XMLWordPrintable

Details

    Description

      We ran into an issue with the WildFly Infinispan subsystem configuration for our custom redis cache implementation when upgrading from 22.x to 24.0.0.1.

      Basically the configuration attribute 'module' changed to 'modules' and this was not implemented properly in the Infinispan subsystem. This causes a basic configuration to fail on WildFly startup with ClassCastException stating that a Module cannot be cast to an ArrayList.

      Example of our configuration for our store:

      <subsystem xmlns="urn:jboss:domain:infinispan:13.0">
          <cache-container name="web" default-cache="session" marshaller="PROTOSTREAM" modules="org.wildfly.clustering.web.infinispan">
              <local-cache name="session" modules="org.infinispan.persistence.redis">
                  <store class="org.infinispan.persistence.redis.configuration.WildflyRedisStoreConfigurationBuilder" passivation="false" purge="false">
                      <property name="connectionTimeout">2000</property>
                      <property name="socketTimeout">2000</property>
                      <property name="masterName"></property>
                      <property name="database">0</property>
                      <property name="maxRedirections">5</property>
                      <property name="topology">SERVER</property>
                      <property name="servers">${env.REDIS_HOST}:${env.REDIS_PORT}</property>
                  </store>
              </local-cache>
              <local-cache name="sso"/>
              <local-cache name="routing"/>
          </cache-container>
          ...
      </subsystem>

      The startup fails because in the org.jboss.as.clustering.infinispan.subsystem.CustomStoreServiceConfigurator class module field was changed to be populated from configuration attribute modules, but the type was not changed to ArrayList.

      I propose the following changes to the org.jboss.as.clustering.infinispan.subsystem.CustomStoreServiceConfigurator class:
      https://github.com/wildfly/wildfly/blob/main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreServiceConfigurator.java

      Index: clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CustomStoreServiceConfigurator.java
      
      <+>UTF-8
      ===================================================================
      @@ -44,13 +44,13 @@
        */
       public class CustomStoreServiceConfigurator extends StoreServiceConfigurator<CustomStoreConfiguration, CustomStoreConfigurationBuilder> {
       
      -    private final SupplierDependency<Module> module;
      +    private final SupplierDependency<java.util.ArrayList<Module>> modules;
       
           private volatile String className;
       
           CustomStoreServiceConfigurator(PathAddress address) {
               super(address, CustomStoreConfigurationBuilder.class);
      -        this.module = new ServiceSupplierDependency<>(CacheComponent.MODULES.getServiceName(address.getParent()));
      +        this.modules = new ServiceSupplierDependency<>(CacheComponent.MODULES.getServiceName(address.getParent()));
           }
       
           @Override
      @@ -61,7 +61,7 @@
       
           @Override
           public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) {
      -        return super.register(this.module.register(builder));
      +        return super.register(this.modules.register(builder));
           }
       
           @Override
      @@ -70,7 +70,7 @@
               StoreConfiguration store = persistence.stores().get(0);
               try {
                   @SuppressWarnings("unchecked")
      -            Class<StoreConfigurationBuilder<?, ?>> storeClass = (Class<StoreConfigurationBuilder<?, ?>>) this.module.get().getClassLoader().loadClass(this.className).asSubclass(StoreConfigurationBuilder.class);
      +            Class<StoreConfigurationBuilder<?, ?>> storeClass = (Class<StoreConfigurationBuilder<?, ?>>) this.modules.get().get(0).getClassLoader().loadClass(this.className).asSubclass(StoreConfigurationBuilder.class);
                   return new ConfigurationBuilder().persistence().passivation(persistence.passivation()).addStore(storeClass)
                           .async().read(store.async())
                           .fetchPersistentState(store.fetchPersistentState()) 

      With these changes, the custom store configuration succeeds.

      Other information:

      I believe the module → modules changes was introduced in https://github.com/wildfly/wildfly/releases/tag/23.0.0.Final

      The changes related to Infinispan module to allow it to compile but not work (at least for our configuration):

      https://issues.redhat.com/browse/WFLY-13519

      https://github.com/wildfly/wildfly/pull/13641

      Attachments

        Issue Links

          Activity

            People

              pferraro@redhat.com Paul Ferraro
              matti.heinola Matti Heinola (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: