From b8fc956a4db6f892e1bd30aa4b881f9664ed29e0 Mon Sep 17 00:00:00 2001 From: Takanobu Asanuma Date: Tue, 15 Jun 2021 16:50:09 +0900 Subject: [PATCH] HDFS-16068. WebHdfsFileSystem has a possible connection leak in connection with HttpFS (#3104) (cherry picked from commit 839fcf7682270bc6ba151875549d64d81917f425) --- .../java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java index e5a7f8b0163..1e58995c3a3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java @@ -2448,10 +2448,12 @@ public class WebHdfsFileSystem extends FileSystem @VisibleForTesting void closeInputStream(RunnerState rs) throws IOException { if (in != null) { - IOUtils.close(cachedConnection); in = null; } - cachedConnection = null; + if (cachedConnection != null) { + IOUtils.close(cachedConnection); + cachedConnection = null; + } runnerState = rs; }