Skip to content

Commit c64a5f8

Browse files
committed
ensure default RecordFilterStrategy#filterBatch returns a mutable list
Signed-off-by: Janek Lasocki-Biczysko <[email protected]>
1 parent 13652e7 commit c64a5f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/RecordFilterStrategy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.kafka.listener.adapter;
1818

19+
import java.util.Arrays;
1920
import java.util.List;
2021

2122
import org.apache.kafka.clients.consumer.ConsumerRecord;
@@ -50,8 +51,10 @@ public interface RecordFilterStrategy<K, V> {
5051
* @return the filtered records.
5152
* @since 2.8
5253
*/
54+
@SuppressWarnings("unchecked")
5355
default List<ConsumerRecord<K, V>> filterBatch(List<ConsumerRecord<K, V>> records) {
54-
return records.stream().filter(record -> !this.filter(record)).toList();
56+
var recordsArray = records.stream().filter(record -> !this.filter(record)).toArray(ConsumerRecord[]::new);
57+
return Arrays.asList(recordsArray);
5558
}
5659

5760
/**

0 commit comments

Comments
 (0)