-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-17509. RBF: Fix ClientProtocol.concat will throw NPE if tgr is a empty file. #6784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
97bffaa
7b8c582
382c3f8
0aa6a1e
e1fea88
acc8139
61d08c5
0c3ea01
7a591b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1163,6 +1163,21 @@ public void testProxyGetPreferedBlockSize() throws Exception { | |
| routerProtocol, nnProtocol, m, new Object[] {badPath}); | ||
| } | ||
|
|
||
| private void testConcat( | ||
| String source, String target, boolean failureExpected, boolean verfiyException, String msg) { | ||
| boolean failure = false; | ||
| try { | ||
| // Concat test file with fill block length file via router | ||
| routerProtocol.concat(target, new String[] {source}); | ||
| } catch (IOException ex) { | ||
| failure = true; | ||
| if (verfiyException) { | ||
| assertExceptionContains(msg, ex); | ||
| } | ||
| } | ||
| assertEquals(failureExpected, failure); | ||
| } | ||
|
|
||
| private void testConcat( | ||
| String source, String target, boolean failureExpected) { | ||
| boolean failure = false; | ||
|
|
@@ -1224,6 +1239,26 @@ public void testProxyConcatFile() throws Exception { | |
| String badPath = "/unknownlocation/unknowndir"; | ||
| compareResponses(routerProtocol, nnProtocol, m, | ||
| new Object[] {badPath, new String[] {routerFile}}); | ||
|
|
||
| // Test when concat trg is a empty file | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we also need to check the empty source file.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there is a empty source file, it will throw exception in namenode. This behaiver is as same as with dfsrouter.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the namenode and rbf throw the same Exception? Maybe RBF throws NPE, but NN throws
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When srclist has a empty file ,both namenode and dfsrouter will throw the same IOException
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you modify the UT to cover the case that one or more source files are empty?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test for a empty src file |
||
| createFile(routerFS, existingFile, existingFileSize); | ||
| String sameRouterEmptyFile = | ||
| cluster.getFederatedTestDirectoryForNS(sameNameservice) + | ||
| "_newemptyfile"; | ||
| createFile(routerFS, sameRouterEmptyFile, 0); | ||
| // Concat in same namespaces, succeeds | ||
| testConcat(existingFile, sameRouterEmptyFile, false); | ||
| FileStatus mergedStatus = getFileStatus(routerFS, sameRouterEmptyFile); | ||
| assertEquals(existingFileSize, mergedStatus.getLen()); | ||
|
|
||
| // Test when concat srclist has some empty file, namenode will throw IOException. | ||
| String srcEmptyFile = cluster.getFederatedTestDirectoryForNS(sameNameservice) + "_srcEmptyFile"; | ||
| createFile(routerFS, srcEmptyFile, 0); | ||
| String targetFile = cluster.getFederatedTestDirectoryForNS(sameNameservice) + "_targetFile"; | ||
| createFile(routerFS, targetFile, existingFileSize); | ||
| // Concat in same namespaces, succeeds | ||
| testConcat(srcEmptyFile, targetFile, true, true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here please check if the exception is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks |
||
| "concat: source file " + srcEmptyFile + " is invalid or empty or underConstruction"); | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.