Skip to content

Commit

Permalink
retain closeQuietly feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sumangala17 committed Aug 31, 2021
1 parent 737c7f3 commit 17810db
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ private static void loadMap(HashMap<String, String> cache, String fileLocation,
LOG.debug("Loading identity map from file {}", fileLocation);
int errorRecord = 0;
File file = new File(fileLocation);
try (LineIterator it = FileUtils.lineIterator(file, "UTF-8")) {
LineIterator it = null;
try {
it = FileUtils.lineIterator(file, "UTF-8");
while (it.hasNext()) {
String line = it.nextLine();
if (!Strings.isNullOrEmpty(line.trim()) && !line.startsWith(HASH)) {
Expand All @@ -186,6 +188,14 @@ private static void loadMap(HashMap<String, String> cache, String fileLocation,
LOG.debug("Loaded map stats - File: {}, Loaded: {}, Error: {} ", fileLocation, cache.size(), errorRecord);
} catch (ArrayIndexOutOfBoundsException e) {
LOG.error("Error while parsing mapping file", e);
} finally {
try {
if (it != null) {
it.close();
}
} catch (IOException ioe) {
LOG.error("IOException thrown on LineIterator close");
}
}
}
}

0 comments on commit 17810db

Please sign in to comment.