kaijchen commented on code in PR #3323:
URL: https://github.com/apache/ozone/pull/3323#discussion_r854095099
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/ChunkUtils.java:
##########
@@ -383,14 +383,21 @@ private static ContainerProtos.Result translate(Exception
cause) {
* Checks if the block file length is equal to the chunk offset.
*
*/
- public static void validateChunkSize(File chunkFile, ChunkInfo chunkInfo)
+ public static void validateChunkSize(FileChannel fileChannel,
+ ChunkInfo chunkInfo, String fileName)
throws StorageContainerException {
long offset = chunkInfo.getOffset();
- long len = chunkFile.length();
- if (chunkFile.length() != offset) {
+ long fileLen;
+ try {
+ fileLen = fileChannel.size();
+ } catch (IOException e) {
+ throw new StorageContainerException("IO error encountered while " +
+ "getting the file size for " + fileName, CHUNK_FILE_INCONSISTENCY);
+ }
+ if (fileLen != offset) {
throw new StorageContainerException(
- "Chunk file offset " + offset + " does not match blockFile length " +
- len, CHUNK_FILE_INCONSISTENCY);
+ "Chunk offset " + offset + " does not match length " +
+ fileLen + "of blockFile " + fileName, CHUNK_FILE_INCONSISTENCY);
Review Comment:
Missing space here.
```suggestion
fileLen + " of blockFile " + fileName, CHUNK_FILE_INCONSISTENCY);
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]