github-actions[bot] commented on code in PR #40797:
URL: https://github.com/apache/beam/pull/40797#discussion_r4373582854


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/MutationUtils.java:
##########
@@ -459,6 +462,8 @@ public static Object convertValueToBeamFieldType(Value 
value) {
             return value.getTimestampArray();
           case STRING:
             return value.getStringArray();
+          case UUID:
+            return 
value.getUuidArray().stream().map(UUID::toString).collect(toList());

Review Comment:
   **🟡 Medium**: In Cloud Spanner, `ARRAY<UUID>` values can contain `null` 
elements. Using `map(UUID::toString)` directly will throw a 
`NullPointerException` if any element in `value.getUuidArray()` is `null`. 
Guard against `null` elements before calling `toString()`.
   
   ```suggestion
               return value.getUuidArray().stream().map(u -> u == null ? null : 
u.toString()).collect(toList());
   ```



##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/StructUtils.java:
##########
@@ -458,6 +461,8 @@ private static java.time.Instant 
fromSpannerTimestamp(Timestamp spannerTimestamp
         return struct.getDoubleList(column);
       case STRING:
         return struct.getStringList(column);
+      case UUID:
+        return 
struct.getUuidList(column).stream().map(UUID::toString).collect(toList());

Review Comment:
   **🟡 Medium**: `struct.getUuidList(column)` can contain `null` elements when 
a non-null Spanner `ARRAY<UUID>` column has `NULL` entries. Calling 
`UUID::toString` without a null check will throw a `NullPointerException`.
   
   ```suggestion
           return struct.getUuidList(column).stream().map(u -> u == null ? null 
: u.toString()).collect(toList());
   ```



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