sanpwc commented on code in PR #2083:
URL: https://github.com/apache/ignite-3/pull/2083#discussion_r1199124024


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/SortedIndexLocker.java:
##########
@@ -186,21 +151,16 @@ public CompletableFuture<Lock> locksForInsert(UUID txId, 
BinaryRow tableRow, Row
         BinaryTuplePrefix prefix = BinaryTuplePrefix.fromBinaryTuple(key);
 
         // Find next key.
-        Cursor<IndexRow> cursor = storage.scan(prefix, null, 
SortedIndexStorage.GREATER);
+        try (Cursor<IndexRow> cursor = storage.scan(prefix, null, 
SortedIndexStorage.GREATER)) {
+            IndexRow nextRow = cursor.hasNext() ? cursor.next() : null;

Review Comment:
   > In the other hand, we do not know what we will deal with without cursor 
there.
   What do you mean?
   
   Generally it's better to wrap with try-with-resources as less code as 
possible.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/SortedIndexLocker.java:
##########
@@ -186,21 +151,16 @@ public CompletableFuture<Lock> locksForInsert(UUID txId, 
BinaryRow tableRow, Row
         BinaryTuplePrefix prefix = BinaryTuplePrefix.fromBinaryTuple(key);
 
         // Find next key.
-        Cursor<IndexRow> cursor = storage.scan(prefix, null, 
SortedIndexStorage.GREATER);
+        try (Cursor<IndexRow> cursor = storage.scan(prefix, null, 
SortedIndexStorage.GREATER)) {
+            IndexRow nextRow = cursor.hasNext() ? cursor.next() : null;

Review Comment:
   > In the other hand, we do not know what we will deal with without cursor 
there.
   
   What do you mean?
   
   Generally it's better to wrap with try-with-resources as less code as 
possible.



-- 
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-unsubscr...@ignite.apache.org

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

Reply via email to