[#8203] fix: prevent NPE in CreateTagFailureEvent when TagInfo is null#8233
[#8203] fix: prevent NPE in CreateTagFailureEvent when TagInfo is null#8233PCloud63514 wants to merge 2 commits intoapache:mainfrom
Conversation
|
@FANNG1 please help to review. |
|
@PCloud63514 , thanks for your contribution, |
|
@FANNG1 Thanks for your feedback. |
Sorry, I don't have other good first issues for now : ( |
|
@FANNG1 I shared these thoughts with the issue author and asked for their advice. I found the phrase “cheap insurance against hard-to-debug NPEs” very meaningful. Also, since the NameIdentifier constructor internally checks the name, I believe it’s better to rely on the constructor’s responsibility for data integrity rather than causing an early NPE. |
|
It is the internal code (not for the users). The developers should guarantee that it will never be null. If there's a null value, something must be wrong; the fix here tries to hide the issue, which I think is not proper. |
|
Thanks everyone for the discussion. |
What changes were proposed in this pull request?
CreateTagFailureEventconstructor.NameIdentifierwhenTagInfois null.tagInfo()andidentifier()returnnullconsistently if noTagInfois provided.testNullTagInfoDoesNotThrowto verify expected behavior.Why are the changes needed?
TagInfocaused aNullPointerExceptionin the constructor when creating theNameIdentifier.Fix: #8203
Does this PR introduce any user-facing change?
CreateTagFailureEventno longer throws NPE ifTagInfois null.tagInfo()andidentifier()returnnull.How was this patch tested?
CreateTagFailureEventTestverifying nullTagInfodoes not throw.TagInfostill construct a properNameIdentifier.