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

ASF GitHub Bot commented on HDFS-17803:
---------------------------------------

balodesecurity opened a new pull request, #8322:
URL: https://github.com/apache/hadoop/pull/8322

   ## Summary
   
   `DistributedFileSystem.getFileChecksum()` on an empty (zero-byte) file 
always returned an `MD5MD5CRC32GzipFileChecksum` value, even when the client 
was configured with `dfs.checksum.combine.mode=COMPOSITE_CRC`. This was 
misleading and inconsistent with what non-empty files return in the same mode.
   
   ### Root Cause
   In `FileChecksumHelper.FileChecksumComputer.compute()`, the empty-file fast 
path unconditionally constructed an `MD5MD5CRC32GzipFileChecksum` without 
checking `combineMode`.
   
   ### Fix
   Check `combineMode` in the empty-file path:
   - **`COMPOSITE_CRC`**: return `CompositeCrcFileChecksum(crc=0, 
configuredChecksumType, configuredBytesPerCrc)` using the client's configured 
`ChecksumOpt`.
   - **`MD5MD5CRC`**: retain the existing backward-compatible magic value 
(`MD5MD5CRC32GzipFileChecksum(0, 0, md5OfZeros)`) to avoid breaking existing 
tools.
   
   ### Changes
   - `FileChecksumHelper.java`: split the empty-file branch on `combineMode`.
   - `TestGetFileChecksum.java`: add `testEmptyFileChecksumType` verifying both 
modes return the expected `FileChecksum` subclass for a zero-byte file.
   
   ## Test plan
   - [ ] `TestGetFileChecksum#testEmptyFileChecksumType` passes locally ✅
   - [ ] Full module build passes (`mvn package ... -DskipTests`) ✅




> Compute correct checksum type when file is empty/ file length is 0
> ------------------------------------------------------------------
>
>                 Key: HDFS-17803
>                 URL: https://issues.apache.org/jira/browse/HDFS-17803
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: dfsclient
>            Reporter: Chayanika Bhandary
>            Priority: Trivial
>              Labels: pull-request-available
>
> When the file is empty or the file size is 0, the checksum returned is always 
> MD5MD5CRC type even when the selected checksum type is COMPOSITE_CRC. 
> This is misleading and can create confusion while debugging.
>  
> Contributing a fix to this. - [https://github.com/apache/hadoop/pull/7764] 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to