From d77cada182ef805679dc79498d6b6cc6e7f6b6d4 Mon Sep 17 00:00:00 2001 From: Junping Du Date: Wed, 12 Apr 2017 09:34:34 -0700 Subject: [PATCH] YARN-3760. FSDataOutputStream leak in AggregatedLogFormat.LogWriter.close(). Contributed by Haibo Chen. (cherry picked from commit c26ccf1adb3a72df3f68e1150b86b813c691203a) (cherry picked from commit 9d9087a67ad599e678948d5c1036e51cb8cf5e3a) --- .../yarn/logaggregation/AggregatedLogFormat.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java index aa293860a61..a2e124309d1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java @@ -540,14 +540,15 @@ public class AggregatedLogFormat { @Override public void close() { - if (writer != null) { - try { + try { + if (writer != null) { writer.close(); - } catch (IOException e) { - LOG.warn("Exception closing writer", e); } + } catch (Exception e) { + LOG.warn("Exception closing writer", e); + } finally { + IOUtils.closeStream(this.fsDataOStream); } - IOUtils.closeStream(fsDataOStream); } }