未验证 提交 88e7be87 编写于 作者: T TaoZhi 提交者: GitHub

Fix param check of KeyGeneratorConfiguration (#5052)

* check whether the type of keyGenerateAlgorithm is null.

* add use="required" on attribute column of element key-generator.
上级 d205c5de
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.apache.shardingsphere.core.yaml.swapper; package org.apache.shardingsphere.core.yaml.swapper;
import com.google.common.base.Strings;
import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration; import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration;
import org.apache.shardingsphere.core.yaml.config.sharding.YamlKeyGeneratorConfiguration; import org.apache.shardingsphere.core.yaml.config.sharding.YamlKeyGeneratorConfiguration;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader; import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
...@@ -44,7 +45,8 @@ public final class KeyGeneratorConfigurationYamlSwapper implements YamlSwapper<Y ...@@ -44,7 +45,8 @@ public final class KeyGeneratorConfigurationYamlSwapper implements YamlSwapper<Y
@Override @Override
public KeyGeneratorConfiguration swap(final YamlKeyGeneratorConfiguration yamlConfiguration) { public KeyGeneratorConfiguration swap(final YamlKeyGeneratorConfiguration yamlConfiguration) {
KeyGenerateAlgorithm keyGenerateAlgorithm = TypedSPIRegistry.getRegisteredService(KeyGenerateAlgorithm.class, yamlConfiguration.getType(), yamlConfiguration.getProps()); KeyGenerateAlgorithm keyGenerateAlgorithm = !Strings.isNullOrEmpty(yamlConfiguration.getType())
? TypedSPIRegistry.getRegisteredService(KeyGenerateAlgorithm.class, yamlConfiguration.getType(), yamlConfiguration.getProps()) : null;
return new KeyGeneratorConfiguration(yamlConfiguration.getColumn(), keyGenerateAlgorithm); return new KeyGeneratorConfiguration(yamlConfiguration.getColumn(), keyGenerateAlgorithm);
} }
} }
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
<xsd:element name="key-generator"> <xsd:element name="key-generator">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="required" /> <xsd:attribute name="id" type="xsd:string" use="required" />
<xsd:attribute name="column" type="xsd:string" /> <xsd:attribute name="column" type="xsd:string" use="required" />
<xsd:attribute name="algorithm-ref" type="xsd:string" /> <xsd:attribute name="algorithm-ref" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册