Skip to content

[#10134] fix(catalog): prevent NPE when filesetChanges is null#10135

Open
a638011 wants to merge 2 commits intoapache:mainfrom
a638011:fix/alter-fileset-null-safe
Open

[#10134] fix(catalog): prevent NPE when filesetChanges is null#10135
a638011 wants to merge 2 commits intoapache:mainfrom
a638011:fix/alter-fileset-null-safe

Conversation

@a638011
Copy link
Contributor

@a638011 a638011 commented Mar 3, 2026

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.

@justinmclean
Copy link
Member

justinmclean commented Mar 3, 2026

@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.

@mchades mchades requested a review from FANNG1 March 3, 2026 03:09
@a638011 a638011 changed the title fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent (GROOVY-432) Mar 3, 2026
@a638011 a638011 changed the title fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent (GROOVY-432) [GROOVY-432] fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011
Copy link
Contributor Author

a638011 commented Mar 3, 2026

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 a638011 changed the title [GROOVY-432] fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011 a638011 changed the title [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix: prevent NPE when filesetChanges is null Mar 3, 2026
@a638011 a638011 changed the title [#432] fix: prevent NPE when filesetChanges is null [#432] fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011 a638011 changed the title [#432] fix: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011 a638011 changed the title [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix: fileset: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011 a638011 changed the title [#432] fix: fileset: prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent Mar 3, 2026
@a638011 a638011 changed the title [#432] fix(fileset): prevent NPE when filesetChanges is null in AlterFilesetFailureEvent [#432] fix: prevent NPE when filesetChanges is null Mar 3, 2026
@a638011 a638011 changed the title [#432] fix: prevent NPE when filesetChanges is null [#10134] fix(catalog): prevent NPE when filesetChanges is null Mar 3, 2026
@justinmclean
Copy link
Member

@a638011 We use spotless to make sure code is consistently formatted. You'll need to run ./gradlew :core:spotlessApply and push your changes to correct the CI failure.

@a638011
Copy link
Contributor Author

a638011 commented Mar 4, 2026

Thanks @justinmclean! I'll run ./gradlew :core:spotlessApply locally and push the changes. The CI is taking a while to run spotless, so I'll update once the formatting is applied.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Code Coverage Report

Overall Project 64.78% 🟢
Files changed 100.0% 🟢

Module Coverage
aliyun 1.73% 🔴
api 46.15% 🟢
authorization-common 85.96% 🟢
aws 1.1% 🔴
azure 2.6% 🔴
catalog-common 10.0% 🔴
catalog-fileset 80.02% 🟢
catalog-hive 80.98% 🟢
catalog-jdbc-clickhouse 77.71% 🟢
catalog-jdbc-common 36.84% 🔴
catalog-jdbc-doris 80.94% 🟢
catalog-jdbc-hologres 57.71% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 78.38% 🟢
catalog-jdbc-postgresql 81.22% 🟢
catalog-jdbc-starrocks 78.27% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 45.07% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 87.15% 🟢
catalog-lakehouse-paimon 77.71% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 77.73% 🟢
common 49.13% 🟢
core 81.2% 🟢
filesystem-hadoop3 76.97% 🟢
flink 38.86% 🔴
flink-runtime 0.0% 🔴
gcp 14.2% 🔴
hadoop-common 10.39% 🔴
hive-metastore-common 45.82% 🟢
iceberg-common 50.21% 🟢
iceberg-rest-server 66.24% 🟢
integration-test-common 0.0% 🔴
jobs 62.55% 🟢
lance-common 23.78% 🔴
lance-rest-server 57.84% 🟢
lineage 53.02% 🟢
optimizer 74.88% 🟢
server 85.76% 🟢
server-common 68.6% 🟢
spark 35.09% 🔴
spark-common 39.88% 🔴
trino-connector 31.62% 🔴
Files
Module File Coverage
core AlterFilesetFailureEvent.java 100.0% 🟢

String user, NameIdentifier identifier, Exception exception, FilesetChange[] filesetChanges) {
super(user, identifier, exception);
this.filesetChanges = filesetChanges.clone();
this.filesetChanges = filesetChanges == null ? null : filesetChanges.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filesetChanges could not be null. Please refer to the following code

FilesetChange[] changes =
request.getUpdates().stream()
.map(FilesetUpdateRequest::filesetChange)
.toArray(FilesetChange[]::new);
Fileset t = dispatcher.alterFileset(ident, changes);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants