Fix some issues from SonarQube analysis

Description

Address some issues discover by SonarQube analysis:

  1. "String#replace" should be preferred to "String#replaceAll" java:S5361

    • The underlying implementation of String::replaceAll calls the java.util.regex.Pattern.compile() method each time it is called even if the first argument is not a regular expression. This has a significant performance cost and therefore should be used with care.

  2. Child class fields should not shadow parent class fields java:S2387

    • e.g: "log" is the name of a field in "SvrProcess"

  3. Should use || instead of | and should use && instead of &

  4. Try-with-resources should be used java:S2093

    • This syntax is safer than the traditional method using try, catch, and finally and hence should be preferred.

  5. Instance methods should not write to "static" fields java:S2696

    • Not thread safe update of static variable in non-static method

  6. Insecure temporary file creation methods should not be used java:S5445

    • Use "Files.createTempDirectory" to create this directory instead

  7. Double-checked locking should not be used java:S2168

Environment

None

Activity

Show:

Carlos Ruiz March 6, 2025 at 10:15 PM

Hi - I think peer review will be easier if we do a ticket per each Sonar rule.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created March 5, 2025 at 12:43 PM
Updated March 10, 2025 at 1:43 PM
Resolved March 6, 2025 at 10:15 PM