[#10134] fix(catalog): prevent NPE when filesetChanges is null#10135
[#10134] fix(catalog): prevent NPE when filesetChanges is null#10135a638011 wants to merge 2 commits intoapache:mainfrom
Conversation
|
@a638011, can you please fix up the PR title to include the issue number? Can you please also request an issue before working on it, so it can be assigned to you. |
|
Hi @justinmclean, thanks for the feedback! I'll update the PR title to include the issue number in the proper format and request the issue for assignment. Could you clarify the expected format? |
|
@a638011 We use spotless to make sure code is consistently formatted. You'll need to run |
|
Thanks @justinmclean! I'll run |
Code Coverage Report
Files
|
| String user, NameIdentifier identifier, Exception exception, FilesetChange[] filesetChanges) { | ||
| super(user, identifier, exception); | ||
| this.filesetChanges = filesetChanges.clone(); | ||
| this.filesetChanges = filesetChanges == null ? null : filesetChanges.clone(); |
There was a problem hiding this comment.
filesetChanges could not be null. Please refer to the following code
There was a problem hiding this comment.
That's only partially true. In the REST path, changes are indeed non-null. But AlterFilesetFailureEvent is not REST-specific. It is built in a generic dispatcher (see FilesetEventDispatcher.java) from varargs FilesetChange... changes.
Java varargs can be called with a null array (e.g. alterFileset(ident, (FilesetChange[]) null)), and the API does notenforce non-null (see FilesetCatalog.java)
What changes were proposed in this pull request?
Fix a potential NullPointerException in AlterFilesetFailureEvent when filesetChanges is null.
Why are the changes needed?
When filesetChanges is null, the constructor calls filesetChanges.clone() which throws NPE. This can happen in failure scenarios where the changes array is not available.
Fix issue #10134
Does this PR introduce any user-facing changes?
No
How was this patch tested?
Added unit test AlterFilesetFailureEventTest that verifies null filesetChanges does not throw NPE.