From 546c66b812d61286f8420e8be6861fff2cb14026 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 7a0857e2e7..df70451dd4 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 @@ -2474,10 +2474,12 @@ InputStream initializeInputStream(HttpURLConnection conn) @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; }