HDDS-10208. Simplify tests using assertThrows in hadoop-hdds#6143
HDDS-10208. Simplify tests using assertThrows in hadoop-hdds#6143adoroszlai merged 3 commits intoapache:masterfrom
Conversation
fapifta
left a comment
There was a problem hiding this comment.
Thank you for the path @wzhallright the changes look good except that one change I left an inline comment on, can you please elaborate on that?
|
|
||
| @Test | ||
| public void testAddAndGetContainer() throws IOException, TimeoutException { | ||
| long containerID = 0; |
There was a problem hiding this comment.
May I ask what is the rationale behind changing this long to AtomicLong? The rest of the patch is really just changing exception testing to assertThrows, is it by chance a leftover from some other work, or intentional?
There was a problem hiding this comment.
I assume it is changed to be able to use in this lambda expression:
I think it's fine. If we want to minimize the diff, we could keep long containerID and change the code above to something like this:
ContainerID cid = ContainerID.valueOf(++containerID);
IOException e = assertThrows(IOException.class,
() -> stateManager.addContainerToPipeline(finalPipeline.getId(), cid));There was a problem hiding this comment.
Thanks for your review! the IntelliJ prompts me variable used in lambda expression should be final or effectively final, so i change long to AtomicLong. Perhaps there is a more elegant solution to this problem?
There was a problem hiding this comment.
@adoroszlai That's a good idea. I will modify it. Thanks
There was a problem hiding this comment.
thank you for the explanation, I did not catch that point. my bad.
|
Thanks @wzhallright for the patch, @fapifta for the review. |
What changes were proposed in this pull request?
Simplify tests using assertThrows in hadoop-hdds
What is the link to the Apache JIRA
HDDS-10208
CI
https://github.com/wzhallright/ozone/actions/runs/7737861963