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


##########
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(u -> u == null ? null : 
u.toString()).collect(toList());

Review Comment:
   **🟠 High**: When an `ARRAY<UUID>` mutation column is `NULL` (e.g., 
`Value.uuidArray(null)`), `value.getUuidArray()` throws an 
`IllegalStateException` (or returns `null`), unlike `getStringArray()` only 
when not dereferenced. Check `value.isNull()` before streaming 
`value.getUuidArray()`.
   
   ```suggestion
               return value.isNull() ? null : 
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/MutationUtils.java:
##########
@@ -439,6 +440,8 @@ public static Object convertValueToBeamFieldType(Value 
value) {
         return value.getTimestamp();
       case STRING:
         return value.getString();
+      case UUID:
+        return value.getUuid().toString();

Review Comment:
   **🟠 High**: `convertValueToBeamFieldType` is invoked for all entries in 
`mutation.asMap()`, including columns bound to `NULL` (e.g., `Value.uuid((UUID) 
null)`). Unlike `value.getString()`, which returns `null` when `value.isNull()` 
is true, `value.getUuid()` returns `null` and calling `.toString()` on it will 
throw a `NullPointerException`.
   
   ```suggestion
           return value.isNull() ? null : value.getUuid().toString();
   ```



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