sunday20111107 opened a new issue #9353:
URL: https://github.com/apache/shardingsphere/issues/9353
## Bug Report
Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at
org.apache.shardingsphere.sharding.algorithm.sharding.mod.HashModShardingAlgorithm.getShardingCount(HashModShardingAlgorithm.java:52)
at
org.apache.shardingsphere.sharding.algorithm.sharding.mod.HashModShardingAlgorithm.init(HashModShardingAlgorithm.java:47)
at
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory.createAlgorithm(ShardingSphereAlgorithmFactory.java:43)
at
org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$new$0(ShardingRule.java:89)
### Which version of ShardingSphere did you use?
5.0.0-alpha
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
### Actual behavior
Exception in thread "main" java.lang.NumberFormatException: null
### Reason analyze (If you can)
i use HASH_MOD shardingAlgorithms,YAML config as follows
shardingAlgorithms:
myDatabasePreciseShardingAlgorithm:
type: HASH_MOD
props:
sharding-count: 2
HashModShardingAlgorithm.getShardingCount will call Properties.getProperty,
sharding-count will be load to Properties as Integer,but Properties.getProperty
is only return string,so getProperty(“sharding-count”) will return null.
HashModShardingAlgorithm should reference ModShardingAlgorithm implements
private int getShardingCount() {
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY),
"Sharding count cannot be null.");
return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));
}
public String getProperty(String key) {
Object oval = super.get(key);
String sval = (oval instanceof String) ? (String)oval : null;
return ((sval == null) && (defaults != null)) ?
defaults.getProperty(key) : sval;
}
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]