Skip to content

Conversation

@keepConcentration
Copy link
Contributor

What changes were proposed in this pull request?

Replace equals() method with == operator for enum comparison in the toAuditLogStatus() method within CompatibilityUtils class. Additionally, add a null safety test case to ensure proper handling of null OperationStatus parameters.

Why are the changes needed?

  1. Using == for enum comparison is more efficient than equals() since enums are singletons in Java
  2. Added test coverage for null parameter handling to ensure robustness

Fix: #8055

Does this PR introduce any user-facing change?

No, this is purely an internal refactoring change.

How was this patch tested?

  1. Existing unit tests continue to pass, ensuring no functional regression
  2. Added a new test case testOperationStatusNullHandling() to verify proper null parameter handling

Copy link
Member

@justinmclean justinmclean left a comment

Choose a reason for hiding this comment

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

Thanks for fixing that.

@justinmclean justinmclean merged commit 27cdf27 into apache:main Aug 15, 2025
28 checks passed
diqiu50 pushed a commit to diqiu50/gravitino that referenced this pull request Sep 15, 2025
…mparison in CompatibilityUtils (apache#8080)

### What changes were proposed in this pull request?

Replace `equals()` method with `==` operator for enum comparison in the
`toAuditLogStatus()` method within `CompatibilityUtils` class.
Additionally, add a null safety test case to ensure proper handling of
null `OperationStatus` parameters.

### Why are the changes needed?

1. Using `==` for enum comparison is more efficient than `equals()`
since enums are singletons in Java
2. Added test coverage for null parameter handling to ensure robustness

Fix: apache#8055

### Does this PR introduce _any_ user-facing change?

No, this is purely an internal refactoring change. 

### How was this patch tested?

1. Existing unit tests continue to pass, ensuring no functional
regression
2. Added a new test case `testOperationStatusNullHandling()` to verify
proper null parameter handling
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] Prevented a potential NullPointerException in CompatibilityUtils.java

2 participants