gemini-code-assist[bot] commented on code in PR #37750:
URL: https://github.com/apache/beam/pull/37750#discussion_r2926012931
##########
sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/DebeziumTransformRegistrar.java:
##########
@@ -123,6 +134,27 @@ public PTransform<PBegin, PCollection<String>>
buildExternal(Configuration confi
readTransform =
readTransform.withMaxTimeToRun(configuration.maxTimeToRun);
}
+ if (configuration.startOffset != null) {
+ Map<String, Object> startOffsetMap = new HashMap<>();
+ for (String property : configuration.startOffset) {
+ String[] parts = property.split("=", 2);
+ String key = parts[0];
+ String value = parts[1];
+ try {
+ startOffsetMap.put(key, Long.parseLong(value));
+ } catch (NumberFormatException e) {
+ startOffsetMap.put(key, value);
+ }
Review Comment:

The code assumes that each property string in `configuration.startOffset`
will contain an `=` character. If a string without `=` is passed from a
cross-language SDK, `property.split("=", 2)` will return an array of length 1,
and accessing `parts[1]` will cause an `ArrayIndexOutOfBoundsException`. It
would be more robust to validate the format of the property string to prevent
the pipeline from crashing with an unexpected error.
```java
String[] parts = property.split("=", 2);
if (parts.length != 2) {
throw new IllegalArgumentException(
"Invalid startOffset property format. Expected 'key=value',
but got: " + property);
}
String key = parts[0];
String value = parts[1];
try {
startOffsetMap.put(key, Long.parseLong(value));
} catch (NumberFormatException e) {
startOffsetMap.put(key, value);
}
```
--
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]