Skip to content

Replace String.format with concatenation in CorrelationIdFormatter #46467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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 @@ -76,7 +76,7 @@ public final class CorrelationIdFormatter {

private CorrelationIdFormatter(List<Part> parts) {
this.parts = parts;
this.blank = String.format("[%s] ", parts.stream().map(Part::blank).collect(Collectors.joining(" ")));
this.blank = "[" + parts.stream().map(Part::blank).collect(Collectors.joining(" ")) + "] ";
Copy link
Contributor

@kzander91 kzander91 Jul 20, 2025

Choose a reason for hiding this comment

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

Why don't we at this point just use the Collectors.joining() variant with a prefix and suffix?

Suggested change
this.blank = "[" + parts.stream().map(Part::blank).collect(Collectors.joining(" ")) + "] ";
this.blank = parts.stream().map(Part::blank).collect(Collectors.joining(" ", "[", "] "));

}

/**
Expand Down