mirror of
https://github.com/ilri/cgspace-java-helpers.git
synced 2025-05-10 07:06:04 +02:00
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:
@ -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();
|
||||
|
Reference in New Issue
Block a user