Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Properties;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerConfig;
Expand Down Expand Up @@ -189,12 +191,9 @@ private static void listen(List<RetryListener> listeners, ConsumerRecords<?, ?>
* @return the String.
*/
public static String recordsToString(ConsumerRecords<?, ?> records) {
StringBuffer sb = new StringBuffer();
records.spliterator().forEachRemaining(rec -> sb
.append(KafkaUtils.format(rec))
.append(','));
sb.deleteCharAt(sb.length() - 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the above implementation also throws exception when records is an empty one

return sb.toString();
return StreamSupport.stream(records.spliterator(), false)
.map(KafkaUtils::format)
.collect(Collectors.joining(","));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setMaxContentLogged(int maxContentLogged) {
@Override
public void onError(ProducerRecord<K, V> record, @Nullable RecordMetadata recordMetadata, Exception exception) {
this.logger.error(exception, () -> {
StringBuffer logOutput = new StringBuffer();
StringBuilder logOutput = new StringBuilder();
logOutput.append("Exception thrown when sending a message");
if (this.includeContents) {
logOutput.append(" with key='")
Expand Down