activemq icon indicating copy to clipboard operation
activemq copied to clipboard

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

Open grigoni opened this issue 6 months ago • 5 comments

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

grigoni avatar Jun 14 '25 14:06 grigoni

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

grigoni avatar Jul 01 '25 04:07 grigoni

@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.

jbonofre avatar Jul 01 '25 05:07 jbonofre

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

grigoni avatar Jul 01 '25 05:07 grigoni

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

jbonofre avatar Jul 01 '25 05:07 jbonofre

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

mattrpav avatar Jul 01 '25 10:07 mattrpav