HDFS-17462. RBF: Fix NPE in Router concat when trg is an empty file. #6722
+36
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of PR
When trg of Router concat is an empty file, it will trigger NPE in Router, and the concat will fail, example:
This is because when trg is an empty file, NameNode will return lastLocatedBlock as null in the response of getBlockLocations. And Router will not check null of lastLocatedBlock returned, instead Router will use it to get block pool id directly.
Trg of concat is an empty file should be allowed in router since this case is supported by concat of NameNode.
This PR fix this NPE exception.
How was this patch tested?
Test cases are:
For code changes:
If lastLocatedBlock returned from getBlockLocations is null in Router concat, it will not be used to get block pool id.
In this case, the block pool id check of trg will be delayed, i.e., concat continues to get and check block pool id of files in src, and only check them.
And the check of trg block pool id can be achieved in following steps, i.e., getLocationForPath and the request of concat forwarded to NameNode.
And exceptions will be thrown if block pool id of trg is not match with the block pool id of any file in src.
LICENSE
,LICENSE-binary
,NOTICE-binary
files?