From 17810db448b949d903f78d79d3934190e2440010 Mon Sep 17 00:00:00 2001 From: sumangala Date: Tue, 31 Aug 2021 12:44:05 +0530 Subject: [PATCH] retain closeQuietly feature --- .../azurebfs/utils/TextFileBasedIdentityHandler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TextFileBasedIdentityHandler.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TextFileBasedIdentityHandler.java index d93a29d1711a0..68de7e000464d 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TextFileBasedIdentityHandler.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TextFileBasedIdentityHandler.java @@ -172,7 +172,9 @@ private static void loadMap(HashMap 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)) { @@ -186,6 +188,14 @@ private static void loadMap(HashMap 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"); + } } } }