Copilot commented on code in PR #2305:
URL: https://github.com/apache/sedona/pull/2305#discussion_r2289611738


##########
common/src/main/java/org/apache/sedona/common/S2Geography/PolylineGeography.java:
##########
@@ -138,22 +138,26 @@ public static PolylineGeography decode(UnsafeInput in, 
EncodeTag tag) throws IOE
     // 2) Skip past any covering cell-IDs written by encodeTagged
     tag.skipCovering(in);
 
-    // 3) Ensure we have at least 4 bytes for the count
-    if (in.available() < Integer.BYTES) {
-      throw new IOException("PolylineGeography.decodeTagged error: 
insufficient header bytes");
-    }
-
-    // 5) Read the number of polylines (4-byte)
-    int count = in.readInt();
+    // 3) Read the number of polylines (4-byte)
+    try {
+      int count = in.readInt();

Review Comment:
   The readInt() operation is moved inside the try block but the count variable 
is still used outside its scope in the for loop. The count variable should be 
declared before the try block to ensure it's accessible in the loop.



##########
common/src/main/java/org/apache/sedona/common/S2Geography/GeographyCollection.java:
##########
@@ -135,20 +135,25 @@ public static GeographyCollection decode(UnsafeInput in, 
EncodeTag tag) throws I
     // Skip any covering data
     tag.skipCovering(in);
 
-    // 3) Ensure we have at least 4 bytes for the count
-    if (in.available() < Integer.BYTES) {
-      throw new IOException("GeographyCollection.decodeTagged error: 
insufficient header bytes");
-    }
+    try {
+      int count = in.readInt();

Review Comment:
   The count variable is declared inside the try block but used in the for loop 
that follows. This creates a scope issue where the count variable won't be 
accessible outside the try block. Declare count before the try block.



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