Skip to content

Conversation

@stokito
Copy link
Contributor

@stokito stokito commented Oct 19, 2025

Also cleanup MessageTest

protected void addStanzaSpecificAttributes(ToStringUtil.Builder builder) {
builder.addValue("type", type)
;
builder.addValue("type", type);
Copy link
Member

Choose a reason for hiding this comment

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

That's an unrelated change in this commit. Also commit subject could be "[core] Fix typo in MessageBuilder"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such kind of change (obvious code style cleanup) is too small for a separate commit: too many of them will distract. I had to mention it in a commit message, but again it will be longer to describe than see.

Copy link
Member

@Flowdalic Flowdalic left a comment

Choose a reason for hiding this comment

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

I don't see the point in switching to String concatenation over StringBuilder. Yes, javac will probably transform String concatenation to StringBuilder and yes, one could argue it's slightly more readable. But am I not convinced that it's worth to change.

In general, please make sure that you don't conflate multiple changes within the same commit (or even, within the same PR). This makes it easier to review stuff, keeps the history clean and increases the chances for undisputed changes to land.

controlLanguages.add(lang3);
controlLanguages.removeAll(languages);
assertTrue(controlLanguages.size() == 0);
assertTrue(controlLanguages.isEmpty());
Copy link
Member

Choose a reason for hiding this comment

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

This change is ok

.addBody("es", "test")
.build();
assertTrue(message.getBodies().size() == 1);
assertEquals(1, message.getBodies().size());
Copy link
Member

Choose a reason for hiding this comment

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

Those changes are ok

var message = assertInstanceOf(Message.class, stanzas.get(0));
// In this case, no xml:lang on the stream or the message and no explicit language argument provided to
// getBody(), it is anbiguous which body we should return.
// getBody(), it is ambiguous which body we should return.
Copy link
Member

Choose a reason for hiding this comment

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

That is also ok.

@stokito
Copy link
Contributor Author

stokito commented Nov 11, 2025

javac will probably transform String concatenation to StringBuilder and yes, one could argue it's slightly more readable

The javac will use concatenation with invokedynamic that potentially may be more optimized because pre-allocates buffer with full length. I changed the code because the IntelliJ proposed the change and it makes it automatically. There is a lot of places where the same change can be applied with one click. Similar warnings may be reported by source quality control systems like Sonarqube and this will make it easier to find more important error. It also minimizes potential errors on code change. There are other places where the IDE can refresh and improve code just automatically with 100% correctness. I just debugged the class a lot and made the cleanup for myself then decided to make a PR on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants