[
https://issues.apache.org/jira/browse/IGNITE-17211?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Evgeny Stanilovsky updated IGNITE-17211:
----------------------------------------
Fix Version/s: 3.2
(was: 3.1)
> Nested polymorphic configuration cannot be without a default type
> -----------------------------------------------------------------
>
> Key: IGNITE-17211
> URL: https://issues.apache.org/jira/browse/IGNITE-17211
> Project: Ignite
> Issue Type: Bug
> Reporter: Kirill Tkalenko
> Priority: Major
> Labels: iep-55, ignite-3, tech-debt
> Fix For: 3.2
>
>
> *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:*
> {noformat}
> 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)
> {noformat}
> *Configuration scheme example:*
> {code:java}
> @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 {
> }
> {code}
> *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*.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)