Skip to content

Commit b255d00

Browse files
author
최왕규
committed
Refactor: use StringBuilder in ConsumerProperties.toString()
Signed-off-by: 최왕규 <[email protected]>
1 parent a7cf43d commit b255d00

File tree

1 file changed

+46
-23
lines changed

1 file changed

+46
-23
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/ConsumerProperties.java

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -510,29 +510,52 @@ public String toString() {
510510
}
511511

512512
protected final String renderProperties() {
513-
return renderTopics()
514-
+ "\n pollTimeout=" + this.pollTimeout
515-
+ (this.groupId != null ? "\n groupId=" + this.groupId : "")
516-
+ (StringUtils.hasText(this.clientId) ? "\n clientId=" + this.clientId : "")
517-
+ (this.consumerRebalanceListener != null
518-
? "\n consumerRebalanceListener=" + this.consumerRebalanceListener
519-
: "")
520-
+ (this.commitCallback != null ? "\n commitCallback=" + this.commitCallback : "")
521-
+ (this.offsetAndMetadataProvider != null ? "\n offsetAndMetadataProvider=" + this.offsetAndMetadataProvider : "")
522-
+ "\n syncCommits=" + this.syncCommits
523-
+ (this.syncCommitTimeout != null ? "\n syncCommitTimeout=" + this.syncCommitTimeout : "")
524-
+ (!this.kafkaConsumerProperties.isEmpty() ? "\n properties=" + this.kafkaConsumerProperties : "")
525-
+ "\n authExceptionRetryInterval=" + this.authExceptionRetryInterval
526-
+ "\n commitRetries=" + this.commitRetries
527-
+ "\n fixTxOffsets" + this.fixTxOffsets;
528-
}
529-
530-
private String renderTopics() {
531-
return (this.topics != null ? "\n topics=" + Arrays.toString(this.topics) : "")
532-
+ (this.topicPattern != null ? "\n topicPattern=" + this.topicPattern : "")
533-
+ (this.topicPartitions != null
534-
? "\n topicPartitions=" + Arrays.toString(this.topicPartitions)
535-
: "");
513+
StringBuilder sb = new StringBuilder();
514+
renderTopics(sb);
515+
sb.append("\n pollTimeout=").append(this.pollTimeout);
516+
517+
if (this.groupId != null) {
518+
sb.append("\n groupId=").append(this.groupId);
519+
}
520+
if (StringUtils.hasText(this.clientId)) {
521+
sb.append("\n clientId=").append(this.clientId);
522+
}
523+
if (this.consumerRebalanceListener != null) {
524+
sb.append("\n consumerRebalanceListener=").append(this.consumerRebalanceListener);
525+
}
526+
if (this.commitCallback != null) {
527+
sb.append("\n commitCallback=").append(this.commitCallback);
528+
}
529+
if (this.offsetAndMetadataProvider != null) {
530+
sb.append("\n offsetAndMetadataProvider=").append(this.offsetAndMetadataProvider);
531+
}
532+
533+
sb.append("\n syncCommits=").append(this.syncCommits);
534+
535+
if (this.syncCommitTimeout != null) {
536+
sb.append("\n syncCommitTimeout=").append(this.syncCommitTimeout);
537+
}
538+
if (!this.kafkaConsumerProperties.isEmpty()) {
539+
sb.append("\n properties=").append(this.kafkaConsumerProperties);
540+
}
541+
542+
sb.append("\n authExceptionRetryInterval=").append(this.authExceptionRetryInterval);
543+
sb.append("\n commitRetries=").append(this.commitRetries);
544+
sb.append("\n fixTxOffsets=").append(this.fixTxOffsets);
545+
546+
return sb.toString();
547+
}
548+
549+
private void renderTopics(StringBuilder sb) {
550+
if (this.topics != null) {
551+
sb.append("\n topics=").append(Arrays.toString(this.topics));
552+
}
553+
if (this.topicPattern != null) {
554+
sb.append("\n topicPattern=").append(this.topicPattern);
555+
}
556+
if (this.topicPartitions != null) {
557+
sb.append("\n topicPartitions=").append(Arrays.toString(this.topicPartitions));
558+
}
536559
}
537560

538561
}

0 commit comments

Comments
 (0)