You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sandynz (via GitHub)" <gi...@apache.org> on 2023/05/18 11:57:20 UTC

[GitHub] [shardingsphere] sandynz commented on a diff in pull request #25717: small fixes added for sonar

sandynz commented on code in PR #25717:
URL: https://github.com/apache/shardingsphere/pull/25717#discussion_r1197729758


##########
kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/AbstractStreamingDataConsistencyCalculateAlgorithm.java:
##########
@@ -78,13 +78,13 @@ public boolean hasNext() {
         @Override
         public DataConsistencyCalculatedResult next() {
             calculateIfNecessary();
-            Optional<DataConsistencyCalculatedResult> nextResult = this.nextResult.get();
+            Optional<DataConsistencyCalculatedResult> nextCalculatedResult = this.nextResult.get();
             this.nextResult.set(null);
-            return nextResult.orElseThrow(NoSuchElementException::new);
+            return nextCalculatedResult.orElseThrow(NoSuchElementException::new);
         }
         
         private void calculateIfNecessary() {
-            if (null == nextResult.get()) {
+            if (!nextResult.get().isPresent()) {
                 nextResult.set(calculateChunk(param));
             }

Review Comment:
   There's `this.nextResult.set(null);`, so `nextResult.get()` might be null.
   
   `if (null == nextResult.get())` looks strange, since `calculateChunk` return `Optional`, there's no better way for now.
   



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org