Skip to content

AMQ-9732: More Code cleanup: use StringBuilder instead of StringBuffer #1461

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

grigoni
Copy link
Contributor

@grigoni grigoni commented Jun 14, 2025

second round about StringBuffer usage

  1. use StringBuilder instead of StringBuffer: this avoids unnecessary sync
  2. use StringBuilder best practice when concatenating
  3. avoid concatenation in logging
  4. use java.nio.charset.StandardCharsets for getBytes
  5. use isEmpty() instead of ...length() > 0
  6. use "0123456789".repeat(Math.max(0, loopSize)); instead of a loop with a SB
  7. some typos fixing

see https://issues.apache.org/jira/browse/AMQ-9732

use StringBuilder best practice when concatenating
avoid concatenation in logging
some typo fixing
@jbonofre jbonofre self-requested a review June 14, 2025 15:17
@grigoni grigoni changed the title More Code cleanup: use StringBuilder instead of StringBuffer AMQ-9732: More Code cleanup: use StringBuilder instead of StringBuffer Jun 14, 2025
@grigoni
Copy link
Contributor Author

grigoni commented Jul 1, 2025

hello @jbonofre , @cshannon
my intention with this PR was to complete StringBuffer cleanup started with AMQ-9720
do you have a chance to review it?
thx

@jbonofre
Copy link
Member

jbonofre commented Jul 1, 2025

@grigoni yes I started to review it. Generally speaking, I'm not a big fan of large PR for code cleanup (when generated by tool or not). It's long to review (it touches different part of the code) and side effects can happen (for instance, using a not expected locale, ...).

So, instead of a super large PR changing everything at once, I would split into smaller chuncks.

That said for this PR, at first glance, it looks good, but I still have to do a new pass.

@grigoni
Copy link
Contributor Author

grigoni commented Jul 1, 2025

@jbonofre
fully agree about large PR, if you prefer I'll split/remove some parts

@jbonofre
Copy link
Member

jbonofre commented Jul 1, 2025

@grigoni it's ok. Don't worry. I will do a pass.

@mattrpav
Copy link
Contributor

mattrpav commented Jul 1, 2025

Breaking up the commits by type of fix and maven module is helpful in the event something need to be reverted.

@grigoni
Copy link
Contributor Author

grigoni commented Jul 8, 2025

@mattrpav splitting makes definetely sense
I've rolled back the commit in my branch and with same code created a new one
which has commits by module and/or by fix type where changes were more specific
see PR : #1471

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.

3 participants