[ 
https://issues.apache.org/jira/browse/HDFS-13247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16390867#comment-16390867
 ] 

John Zhuge commented on HDFS-13247:
-----------------------------------

Please check out 
[try-with-resources|https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html].

> FileInputStream not closed when read the checksum header from the meta file
> ---------------------------------------------------------------------------
>
>                 Key: HDFS-13247
>                 URL: https://issues.apache.org/jira/browse/HDFS-13247
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: datanode
>    Affects Versions: 3.2.0
>            Reporter: liaoyuxiangqin
>            Priority: Major
>
> When i read the computeChecksum() of FsDatasetImpl class in datanode, I found 
> the following code not closed fis after  read the checksum header from the 
> meta file, According to the comments of function readDataChecksum()  we must 
> close inputStream  by the caller. Thanks.
> {code:java|title=FsDatasetImpl.java|borderStyle=solid}
> DataChecksum checksum;
> try (FileInputStream fis =
>  srcReplica.getFileIoProvider().getFileInputStream(
>  srcReplica.getVolume(), srcMeta)) {
>  checksum = BlockMetadataHeader.readDataChecksum(
>  fis, DFSUtilClient.getIoFileBufferSize(conf), srcMeta);
> }
> final byte[] data = new byte[1 << 16];
> final byte[] crcs = new byte[checksum.getChecksumSize(data.length)];
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to