Skip to content

[#8168] Fix NPE in EntityCombinedFileset by initializing hiddenProperties field - #8238

Merged
justinmclean merged 1 commit into
apache:mainfrom
JeonDaehong:main
Aug 22, 2025
Merged

justinmclean merged 1 commit into
apache:mainfrom
JeonDaehong:main

Conversation

@JeonDaehong

@JeonDaehong JeonDaehong commented Aug 21, 2025 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In EntityCombinedFileset.java, the properties() method directly called hiddenProperties.contains() without null checking, which could throw a NullPointerException if hiddenProperties was not initialized. This PR updates the code to initialize hiddenProperties with an empty set and adds null-safe handling in the withHiddenProperties() method.

Why are the changes needed?

Without this fix, calling properties() on an EntityCombinedFileset instance before setting hidden properties could cause NPEs, breaking fileset property retrieval. Adding proper initialization ensures that the object is always in a valid state and handles missing hidden properties gracefully.

Fixes #8168

Does this PR introduce any user-facing change?

No. Valid requests behave the same. Cases where hiddenProperties was not explicitly set are now safely handled without throwing exceptions.

How was this patch tested?

  • Added unit tests to verify that calling properties() without setting hidden properties does not cause exceptions
  • Added tests to ensure null input to withHiddenProperties() is handled safely
  • Added tests to verify that hidden property filtering works correctly when properties are set
  • Verified that existing functionality remains unchanged

@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@justinmclean
Hello! The tests have passed. If there are no issues, I kindly request a merge.

@justinmclean justinmclean left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing this.

@justinmclean
justinmclean merged commit fd0828c into apache:main Aug 22, 2025
diqiu50 pushed a commit to diqiu50/gravitino that referenced this pull request Sep 15, 2025
…Properties field (apache#8238)

### What changes were proposed in this pull request?
In `EntityCombinedFileset.java`, the `properties()` method directly
called `hiddenProperties.contains()` without null checking, which could
throw a `NullPointerException` if `hiddenProperties` was not
initialized. This PR updates the code to initialize `hiddenProperties`
with an empty set and adds null-safe handling in the
`withHiddenProperties()` method.

### Why are the changes needed?
Without this fix, calling `properties()` on an `EntityCombinedFileset`
instance before setting hidden properties could cause NPEs, breaking
fileset property retrieval. Adding proper initialization ensures that
the object is always in a valid state and handles missing hidden
properties gracefully.

Fixes apache#8168

### Does this PR introduce any user-facing change?
No. Valid requests behave the same. Cases where `hiddenProperties` was
not explicitly set are now safely handled without throwing exceptions.

### How was this patch tested?
* Added unit tests to verify that calling `properties()` without setting
hidden properties does not cause exceptions
* Added tests to ensure null input to `withHiddenProperties()` is
handled safely
* Added tests to verify that hidden property filtering works correctly
when properties are set
* Verified that existing functionality remains unchanged
bharos pushed a commit to bharos/gravitino that referenced this pull request Oct 3, 2025
…Properties field (apache#8238)

### What changes were proposed in this pull request?
In `EntityCombinedFileset.java`, the `properties()` method directly
called `hiddenProperties.contains()` without null checking, which could
throw a `NullPointerException` if `hiddenProperties` was not
initialized. This PR updates the code to initialize `hiddenProperties`
with an empty set and adds null-safe handling in the
`withHiddenProperties()` method.

### Why are the changes needed?
Without this fix, calling `properties()` on an `EntityCombinedFileset`
instance before setting hidden properties could cause NPEs, breaking
fileset property retrieval. Adding proper initialization ensures that
the object is always in a valid state and handles missing hidden
properties gracefully.

Fixes apache#8168

### Does this PR introduce any user-facing change?
No. Valid requests behave the same. Cases where `hiddenProperties` was
not explicitly set are now safely handled without throwing exceptions.

### How was this patch tested?
* Added unit tests to verify that calling `properties()` without setting
hidden properties does not cause exceptions
* Added tests to ensure null input to `withHiddenProperties()` is
handled safely
* Added tests to verify that hidden property filtering works correctly
when properties are set
* Verified that existing functionality remains unchanged
bharos pushed a commit to bharos/gravitino that referenced this pull request Oct 7, 2025
…Properties field (apache#8238)

### What changes were proposed in this pull request?
In `EntityCombinedFileset.java`, the `properties()` method directly
called `hiddenProperties.contains()` without null checking, which could
throw a `NullPointerException` if `hiddenProperties` was not
initialized. This PR updates the code to initialize `hiddenProperties`
with an empty set and adds null-safe handling in the
`withHiddenProperties()` method.

### Why are the changes needed?
Without this fix, calling `properties()` on an `EntityCombinedFileset`
instance before setting hidden properties could cause NPEs, breaking
fileset property retrieval. Adding proper initialization ensures that
the object is always in a valid state and handles missing hidden
properties gracefully.

Fixes apache#8168

### Does this PR introduce any user-facing change?
No. Valid requests behave the same. Cases where `hiddenProperties` was
not explicitly set are now safely handled without throwing exceptions.

### How was this patch tested?
* Added unit tests to verify that calling `properties()` without setting
hidden properties does not cause exceptions
* Added tests to ensure null input to `withHiddenProperties()` is
handled safely
* Added tests to verify that hidden property filtering works correctly
when properties are set
* Verified that existing functionality remains unchanged
danhuawang pushed a commit to danhuawang/gravitino that referenced this pull request Jun 9, 2026
…Properties field (apache#8238)

### What changes were proposed in this pull request?
In `EntityCombinedFileset.java`, the `properties()` method directly
called `hiddenProperties.contains()` without null checking, which could
throw a `NullPointerException` if `hiddenProperties` was not
initialized. This PR updates the code to initialize `hiddenProperties`
with an empty set and adds null-safe handling in the
`withHiddenProperties()` method.

### Why are the changes needed?
Without this fix, calling `properties()` on an `EntityCombinedFileset`
instance before setting hidden properties could cause NPEs, breaking
fileset property retrieval. Adding proper initialization ensures that
the object is always in a valid state and handles missing hidden
properties gracefully.

Fixes apache#8168

### Does this PR introduce any user-facing change?
No. Valid requests behave the same. Cases where `hiddenProperties` was
not explicitly set are now safely handled without throwing exceptions.

### How was this patch tested?
* Added unit tests to verify that calling `properties()` without setting
hidden properties does not cause exceptions
* Added tests to ensure null input to `withHiddenProperties()` is
handled safely
* Added tests to verify that hidden property filtering works correctly
when properties are set
* Verified that existing functionality remains unchanged
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.

[Improvement] Possible Null Pointer Exception in TestEntityCombinedFileset.java

2 participants