This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 6715f2755c4 Fix sonar issue on CosIdSnowflakeKeyGenerateAlgorithm and
SnowflakeKeyGenerateAlgorithm (#25807)
6715f2755c4 is described below
commit 6715f2755c4675124eaee0d4bf0302ee6f534e7a
Author: Liang Zhang <[email protected]>
AuthorDate: Sat May 20 16:33:47 2023 +0800
Fix sonar issue on CosIdSnowflakeKeyGenerateAlgorithm and
SnowflakeKeyGenerateAlgorithm (#25807)
* Fix sonar issue on CosIdSnowflakeKeyGenerateAlgorithm and
SnowflakeKeyGenerateAlgorithm
* Fix sonar issue on CosIdSnowflakeKeyGenerateAlgorithm and
SnowflakeKeyGenerateAlgorithm
* Fix sonar issue on ShardingTableRuleStatementChecker
---
.../sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java | 4 ++--
.../distsql/handler/checker/ShardingTableRuleStatementChecker.java | 4 ++--
.../cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
index 1b24020036f..33f04fb593f 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import java.time.Instant;
import java.time.LocalDateTime;
-import java.time.ZoneOffset;
+import java.time.ZoneId;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -87,7 +87,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements
KeyGenerateAlgorithm
private int maxTolerateTimeDifferenceMillis;
static {
- EPOCH = LocalDateTime.of(2016, 11, 1, 0, 0,
0).toInstant(ZoneOffset.systemDefault().getRules().getOffset(Instant.now())).toEpochMilli();
+ EPOCH = LocalDateTime.of(2016, 11, 1, 0, 0,
0).toInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())).toEpochMilli();
}
@Override
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index f54ec7c8e3a..b69ba30cfa0 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -147,8 +147,8 @@ public final class ShardingTableRuleStatementChecker {
checkDataSources(databaseName, rules, database);
checkKeyGenerators(rules);
checkAuditors(rules);
- checkAutoTableRule(rules.stream().filter(each -> each instanceof
AutoTableRuleSegment).map(AutoTableRuleSegment.class::cast).collect(Collectors.toList()));
- checkTableRule(databaseName, rules.stream().filter(each -> each
instanceof
TableRuleSegment).map(TableRuleSegment.class::cast).collect(Collectors.toList()));
+
checkAutoTableRule(rules.stream().filter(AutoTableRuleSegment.class::isInstance).map(AutoTableRuleSegment.class::cast).collect(Collectors.toList()));
+ checkTableRule(databaseName,
rules.stream().filter(TableRuleSegment.class::isInstance).map(TableRuleSegment.class::cast).collect(Collectors.toList()));
if (!isCreated) {
checkBindingTableRules(rules, currentRuleConfig);
}
diff --git
a/features/sharding/plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
b/features/sharding/plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
index 5ba8f7cb701..2a3694a592e 100644
---
a/features/sharding/plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
+++
b/features/sharding/plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
@@ -31,7 +31,7 @@ import
org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import java.time.Instant;
import java.time.LocalDateTime;
-import java.time.ZoneOffset;
+import java.time.ZoneId;
import java.util.Properties;
/**
@@ -54,7 +54,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm
implements KeyGenerateAlgo
private long epoch;
static {
- DEFAULT_EPOCH = LocalDateTime.of(2016, 11, 1, 0, 0,
0).toInstant(ZoneOffset.systemDefault().getRules().getOffset(Instant.now())).toEpochMilli();
+ DEFAULT_EPOCH = LocalDateTime.of(2016, 11, 1, 0, 0,
0).toInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())).toEpochMilli();
}
@Override