Skip to content

Commit 3dba618

Browse files
authored
fix: handle empty string message values in CloudPubSubSinkTask (#431)
Treat empty string ("") payloads as equivalent to null when no attributes are present. Previously, only null values were checked, allowing empty messages to pass through and potentially stall processing. Updated the condition to use attributes.isEmpty() and include value.isEmpty() alongside the null check to ensure invalid messages are consistently skipped.
1 parent e1dd4e1 commit 3dba618

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main/java/com/google/pubsub/kafka/sink/CloudPubSubSinkTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void put(Collection<SinkRecord> sinkRecords) {
176176
attributes.put(header.key(), header.value().toString());
177177
}
178178
}
179-
if (attributes.size() == 0 && value == null) {
179+
if (attributes.isEmpty() && (value == null || value.isEmpty())) {
180180
log.warn("Message received with no value and no attributes. Not publishing message");
181181
SettableApiFuture<String> nullMessageFuture = SettableApiFuture.<String>create();
182182
nullMessageFuture.set("No message");

0 commit comments

Comments
 (0)