You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by sn...@apache.org on 2023/11/28 20:49:05 UTC

(pinot) branch master updated: Fix the memory leak issue on `CommonsConfigurationUtils` (#12056)

This is an automated email from the ASF dual-hosted git repository.

snlee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new bfd7dce57e Fix the memory leak issue on `CommonsConfigurationUtils` (#12056)
bfd7dce57e is described below

commit bfd7dce57e84bb7a3e2a7c349b0f44fa54305e61
Author: Seunghyun Lee <se...@startree.ai>
AuthorDate: Tue Nov 28 12:48:59 2023 -0800

    Fix the memory leak issue on `CommonsConfigurationUtils` (#12056)
    
    Existing code does not release the outputstream that has been
    created and caused the file handler leak.
---
 .../java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java
index fd9e84fd3a..a7da9f9dd7 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/env/CommonsConfigurationUtils.java
@@ -20,7 +20,6 @@ package org.apache.pinot.spi.env;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -107,11 +106,12 @@ public class CommonsConfigurationUtils {
       // Explicitly providing the input stream on load bypasses the problem.
       propertiesConfiguration.setFile(file);
       if (file.exists()) {
-        propertiesConfiguration.load(new FileInputStream(file));
+        try (InputStream in = new FileInputStream(file)) {
+          propertiesConfiguration.load(in);
+        }
       }
-
       return propertiesConfiguration;
-    } catch (org.apache.commons.configuration.ConfigurationException | FileNotFoundException e) {
+    } catch (org.apache.commons.configuration.ConfigurationException | IOException e) {
       throw new RuntimeException(e);
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org