Skip to content

Conversation

@AymanDF
Copy link

@AymanDF AymanDF commented May 31, 2016

This pull request is focused on resolving occurrences of Sonar rule
squid:S2095 - “Resources should be closed”.

You can find more information about the issue here:
https://dev.eclipse.org/sonar/rules/show/squid:S2095

Please let me know if you have any questions.
Ayman Abdelghany.

Formatter f = new Formatter(locale);
f.format(formatString, o);
return f.toString();
String str = f.toString();
Copy link
Member

Choose a reason for hiding this comment

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

💡 This code should be in a try/finally for exception-safe closing of the Formatter instance.

@AymanDF
Copy link
Author

AymanDF commented Jun 8, 2016

Done

Formatter f = new Formatter(locale);
f.format(formatString, o);
return f.toString();
Formatter f = null;
Copy link
Member

Choose a reason for hiding this comment

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

💡 Slight simplification

Formatter f = new Formatter(locale);
try {
  f.format(formatString, o);
  return f.toString();
} finally {
  f.close();
}

adding try/finally

simplify code
@sharwell
Copy link
Member

👍

@parrt
Copy link
Member

parrt commented Nov 7, 2018

doing similarly manually 40bfd17 . closing.

@parrt parrt closed this Nov 7, 2018
@parrt parrt added this to the 4.0.9 milestone Nov 7, 2018
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