Add TODO about using try-with-resource

This would automatically close the BufferedReader after we are done
with it, but it also means that the JSON object we create is lost
when we exit the try() scope...

See: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
This commit is contained in:
Alan Orth 2020-07-31 22:25:38 +03:00
parent af708933b2
commit 9089ffb66f
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
1 changed files with 1 additions and 0 deletions

View File

@ -72,6 +72,7 @@ public class CountryCodeTagger extends AbstractCurationTask
} else {
Gson gson = new Gson();
// TODO: convert to try: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream(isocodesJsonPath)));
CountriesVocabulary isocodesCountriesJson = gson.fromJson(reader, CountriesVocabulary.class);
reader.close();