Skip to content

Commit 17810db

Browse files
committed
retain closeQuietly feature
1 parent 737c7f3 commit 17810db

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TextFileBasedIdentityHandler.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ private static void loadMap(HashMap<String, String> cache, String fileLocation,
172172
LOG.debug("Loading identity map from file {}", fileLocation);
173173
int errorRecord = 0;
174174
File file = new File(fileLocation);
175-
try (LineIterator it = FileUtils.lineIterator(file, "UTF-8")) {
175+
LineIterator it = null;
176+
try {
177+
it = FileUtils.lineIterator(file, "UTF-8");
176178
while (it.hasNext()) {
177179
String line = it.nextLine();
178180
if (!Strings.isNullOrEmpty(line.trim()) && !line.startsWith(HASH)) {
@@ -186,6 +188,14 @@ private static void loadMap(HashMap<String, String> cache, String fileLocation,
186188
LOG.debug("Loaded map stats - File: {}, Loaded: {}, Error: {} ", fileLocation, cache.size(), errorRecord);
187189
} catch (ArrayIndexOutOfBoundsException e) {
188190
LOG.error("Error while parsing mapping file", e);
191+
} finally {
192+
try {
193+
if (it != null) {
194+
it.close();
195+
}
196+
} catch (IOException ioe) {
197+
LOG.error("IOException thrown on LineIterator close");
198+
}
189199
}
190200
}
191201
}

0 commit comments

Comments
 (0)