You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/08/17 04:56:48 UTC

[shardingsphere] branch master updated: Conditional expressions adjustment (#11820)

This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 44dd0cf  Conditional expressions adjustment (#11820)
44dd0cf is described below

commit 44dd0cf4698902e474a228b73a2d094808254d2f
Author: yx9o <ya...@163.com>
AuthorDate: Tue Aug 17 12:56:20 2021 +0800

    Conditional expressions adjustment (#11820)
---
 .../algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java | 2 +-
 .../governance/core/lock/watcher/LockChangedWatcher.java              | 4 ++--
 .../core/convert/converter/impl/ExpressionSqlNodeConverter.java       | 4 ++--
 .../namespace/registry/ShardingSphereAlgorithmBeanRegistry.java       | 2 +-
 .../env/database/embedded/type/PostgreSQLEmbeddedDatabase.java        | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
index cfdcc61..8bf799f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/BoundaryBasedRangeShardingAlgorithm.java
@@ -48,7 +48,7 @@ public final class BoundaryBasedRangeShardingAlgorithm extends AbstractRangeShar
         Map<Integer, Range<Long>> result = new HashMap<>(partitionRanges.size() + 1, 1);
         for (int i = 0; i < partitionRanges.size(); i++) {
             Long rangeValue = partitionRanges.get(i);
-            if (i == 0) {
+            if (0 == i) {
                 result.put(0, Range.lessThan(rangeValue));
             } else {
                 Long previousRangeValue = partitionRanges.get(i - 1);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/watcher/LockChangedWatcher.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/watcher/LockChangedWatcher.java
index c63ac39..7c585d8 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/watcher/LockChangedWatcher.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/watcher/LockChangedWatcher.java
@@ -48,9 +48,9 @@ public final class LockChangedWatcher implements GovernanceWatcher<GovernanceEve
     @Override
     public Optional<GovernanceEvent> createGovernanceEvent(final DataChangedEvent event) {
         if (!event.getKey().equals(LockNode.getLockRootNodePath()) && LockNode.getLockName(event.getKey()).isPresent()) {
-            if (event.getType() == Type.ADDED) {
+            if (Type.ADDED == event.getType()) {
                 return Optional.of(new LockNotificationEvent(LockNode.getLockName(event.getKey()).get()));
-            } else if (event.getType() == Type.DELETED) {
+            } else if (Type.DELETED == event.getType()) {
                 return Optional.of(new LockReleasedEvent(LockNode.getLockName(event.getKey()).get()));
             }
         }
diff --git a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/impl/ExpressionSqlNodeConverter.java b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/impl/ExpressionSqlNodeConverter.java
index 42ef3af..c507d22 100644
--- a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/impl/ExpressionSqlNodeConverter.java
+++ b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/impl/ExpressionSqlNodeConverter.java
@@ -35,7 +35,7 @@ public final class ExpressionSqlNodeConverter implements SqlNodeConverter<Expres
     
     @Override
     public Optional<SqlNode> convert(final ExpressionSegment expression) {
-        if (expression == null) {
+        if (null == expression) {
             return Optional.empty();
         }
         if (expression instanceof LiteralExpressionSegment) {
@@ -50,6 +50,6 @@ public final class ExpressionSqlNodeConverter implements SqlNodeConverter<Expres
         } else if (expression instanceof ColumnSegment) {
             return new ColumnSqlNodeConverter().convert((ColumnSegment) expression);
         }
-        throw new UnsupportedOperationException("unsupportd TableSegment type: " + expression.getClass());
+        throw new UnsupportedOperationException("unsupported TableSegment type: " + expression.getClass());
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/registry/ShardingSphereAlgorithmBeanRegistry.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/registry/ShardingSphereAlgorithmBeanRegistry.java
index acfdb06..bfe11b7 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/registry/ShardingSphereAlgorithmBeanRegistry.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/registry/ShardingSphereAlgorithmBeanRegistry.java
@@ -46,7 +46,7 @@ public final class ShardingSphereAlgorithmBeanRegistry {
         Map<String, RuntimeBeanReference> result = new ManagedMap<>(beanDefinitionNames.length);
         for (String each : beanDefinitionNames) {
             String beanClassName = parserContext.getRegistry().getBeanDefinition(each).getBeanClassName();
-            if (beanClassName != null && beanClassName.equals(algorithmFactoryBeanClassName)) {
+            if (null != beanClassName && beanClassName.equals(algorithmFactoryBeanClassName)) {
                 result.put(each, new RuntimeBeanReference(each));
             }
         }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java
index 1bee0c3..d826018 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java
@@ -114,10 +114,10 @@ public final class PostgreSQLEmbeddedDatabase implements EmbeddedDatabase {
     
     @SneakyThrows
     private ICommandLinePostProcessor privilegedWindowsRunasPostprocessor() {
-        if (Platform.detect() == Platform.Windows) {
+        if (Platform.Windows == Platform.detect()) {
             // Based on https://stackoverflow.com/a/11995662
             int adminCommandResult = Runtime.getRuntime().exec("net session").waitFor();
-            if (adminCommandResult == 0) {
+            if (0 == adminCommandResult) {
                 return runWithoutPrivileges();
             }
         }