Skip to content

KAFKA-19137: Use StandardCharsets.UTF_8 instead of StandardCharsets.UTF_8.name() #19464

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

Merged
merged 3 commits into from
Apr 15, 2025

Conversation

xijiu
Copy link
Contributor

@xijiu xijiu commented Apr 14, 2025

Replace StandardCharsets.UTF_8.name() with StandardCharsets.UTF_8 to
avoid UnsupportedEncodingException and optimize the related code at the
same time.

Reviewers: Ken Huang [email protected], PoAn Yang
[email protected], Chia-Ping Tsai [email protected]

@chia7712
Copy link
Member

@xijiu could you please merge trunk to run CI again?

@github-actions github-actions bot added the small Small PRs label Apr 15, 2025
@xijiu
Copy link
Contributor Author

xijiu commented Apr 15, 2025

@xijiu could you please merge trunk to run CI again?

Yeah, I have merged it, PTAL

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Leave a minor comment.

}
String encodedSource = encodePath(sourceAndTarget.source());
String encodedTarget = encodePath(sourceAndTarget.target());
List<String> restNamespace = Arrays.asList(encodedSource, encodedTarget);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Use List.of.

Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks @xijiu for this patch, left some comments

final ProcessorSupplier<String, Integer, Void, Void> supplier = new PrintedInternal<>(sysOutPrinter).build("processor");
final Processor<String, Integer, Void, Void> processor = supplier.get();

processor.process(new Record<>("good", 2, 0L));
processor.close();
assertThat(sysOut.toString(StandardCharsets.UTF_8.name()), equalTo("[processor]: good, 2\n"));
assertThat(sysOut.toString(StandardCharsets.UTF_8), equalTo("[processor]: good, 2\n"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use assertEquals instead of assertThat

final Processor<String, Integer, Void, Void> processor = new PrintedInternal<>(sysOutPrinter.withLabel("label"))
.build("processor")
.get();

processor.process(new Record<>("hello", 3, 0L));
processor.close();
assertThat(sysOut.toString(StandardCharsets.UTF_8.name()), equalTo("[label]: hello, 3\n"));
assertThat(sysOut.toString(StandardCharsets.UTF_8), equalTo("[label]: hello, 3\n"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto: We should use assertEquals instead of assertThat

final Processor<String, Integer, Void, Void> processor = new PrintedInternal<>(
sysOutPrinter.withKeyValueMapper((key, value) -> String.format("%s -> %d", key, value))
).build("processor").get();
processor.process(new Record<>("hello", 1, 0L));
processor.close();
assertThat(sysOut.toString(StandardCharsets.UTF_8.name()), equalTo("[processor]: hello -> 1\n"));
assertThat(sysOut.toString(StandardCharsets.UTF_8), equalTo("[processor]: hello -> 1\n"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto: We should use assertEquals instead of assertThat

@xijiu
Copy link
Contributor Author

xijiu commented Apr 15, 2025

@FrankYang0529 @m1a2st Thanks very much for the code review, and I have fixed it, PTAL

@chia7712 chia7712 merged commit 8bdd73c into apache:trunk Apr 15, 2025
22 checks passed
@github-actions github-actions bot removed the triage PRs from the community label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants