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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to