Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-17211

Nested polymorphic configuration cannot be without a default type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 3.0
    • None

    Description

      Problem
      If the polymorphic configuration is nested (sub), then when trying to create an instance of the configuration, we will receive the error Polymorphic configuration type is not defined, since the type of the polymorphic configuration is not known and can be changed in the future, in order to get around this limitation, you have to set the default type, which may not always be correct.

      Stack trace example:

      Caused by: java.lang.IllegalStateException: Polymorphic configuration type is not defined: org.apache.ignite.configuration.schemas.table.ColumnDefaultConfigurationSchema. See @PolymorphicConfig documentation.
      	at org.apache.ignite.configuration.schemas.table.ColumnNode.construct(Unknown Source)
      	at org.apache.ignite.internal.configuration.util.ConfigurationUtil$3.visitInnerNode(ConfigurationUtil.java:327)
      	at org.apache.ignite.configuration.schemas.table.ColumnNode.traverseChildren(Unknown Source)
      	at org.apache.ignite.internal.configuration.util.ConfigurationUtil.addDefaults(ConfigurationUtil.java:308)
      	at org.apache.ignite.internal.configuration.tree.NamedListNode.newElementDescriptor(NamedListNode.java:492)
      	at org.apache.ignite.internal.configuration.tree.NamedListNode.create(NamedListNode.java:156)
      

      Configuration scheme example:

      @ConfigurationRoot(rootName = "parent", type = LOCAL)
      public static class ParentConfigurationSchema {
          @ConfigValue
          public ChildConfigurationSchema child;
      }
      
      @PolymorphicConfig
      public static class ChildConfigurationSchema {
          public static final String FIRST = "first";
          public static final String SECOND = "second";
      
          // When creating a configuration instance, there will be an error if there is no default value.
          @PolymorphicId
          public String type;
      }
      
      @PolymorphicConfigInstance(ChildConfigurationSchema.FIRST)
      public static class FirstChildConfigurationSchema extends ChildConfigurationSchema {
      }
      
      @PolymorphicConfigInstance(ChildConfigurationSchema.SECOND)
      public static class SecondChildConfigurationSchema extends ChildConfigurationSchema {
      }
      

      Notes on a possible implementation

      • We can consider weakening the condition of necessarily polymorphic configuration type at the stage of adding default values for configuration fields, you can see here org.apache.ignite.internal.configuration.util.ConfigurationUtil#addDefaults.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ktkalenko@gridgain.com Kirill Tkalenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: