[ 
https://issues.apache.org/jira/browse/HDFS-15791?focusedWorklogId=541410&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-541410
 ]

ASF GitHub Bot logged work on HDFS-15791:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jan/21 00:47
            Start Date: 26/Jan/21 00:47
    Worklog Time Spent: 10m 
      Work Description: Nargeshdb commented on a change in pull request #2652:
URL: https://github.com/apache/hadoop/pull/2652#discussion_r564139504



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
##########
@@ -269,14 +269,20 @@ public InputStream 
getInputStreamForSection(FileSummary.Section section,
                                                 String compressionCodec)
         throws IOException {
       FileInputStream fin = new FileInputStream(filename);
-      FileChannel channel = fin.getChannel();
-      channel.position(section.getOffset());
-      InputStream in = new BufferedInputStream(new LimitInputStream(fin,
-          section.getLength()));
+      try {

Review comment:
       I don't think we can use try-with-resources here, since in the normal 
case, `in` gets returned, and it is a wrapper for `fin`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 541410)
    Time Spent: 0.5h  (was: 20m)

> Possible Resource Leak in FSImageFormatProtobuf
> -----------------------------------------------
>
>                 Key: HDFS-15791
>                 URL: https://issues.apache.org/jira/browse/HDFS-15791
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>            Reporter: Narges Shadab
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> We noticed a possible resource leak 
> [here|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java#L271].
>  If an I/O error occurs at line 
> [273|https://github.com/apache/hadoop/blob/06a5d3437f68546207f18d23fe527895920c756a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java#L273]
>  or 
> [277|https://github.com/apache/hadoop/blob/06a5d3437f68546207f18d23fe527895920c756a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java#L277],
>  {{fin}} remains open since the exception isn't caught locally, and there is 
> no way for any caller to close the FileInputStream
> I'll submit a pull request to fix it.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to