mbaurin opened a new pull request, #8420:
URL: https://github.com/apache/gravitino/pull/8420

   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): support xxx"
        - "[#233] fix: check null before access result in xxx"
        - "[MINOR] refactor: fix typo in variable name"
        - "[MINOR] docs: fix typo in README"
        - "[#255] test: fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   
   Fixed the `AuditInfo.merge()` method to prevent null values from overwriting 
existing non-null values when `overwrite` is set to `true`. The merge logic was 
updated to only overwrite existing values when the source value is non-null.
   
   ### Why are the changes needed?
   
   The current implementation of `AuditInfo.merge()` has a bug where it nulls 
out existing non-null values when merging with `overwrite=true`. This happens 
because the method unconditionally takes values from the source object when 
overwrite is enabled, even if those values are null.
   
   This bug affects multiple EntityCombined classes (Table, Schema, Fileset, 
Topic, Model, ModelVersion) that use this method with `overwrite=true`, 
potentially causing loss of audit information across the system.
   
   Fix: [#(issue)](https://github.com/apache/gravitino/issues/8411)
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is an internal bug fix that preserves existing audit information 
correctly. The behavior change ensures that audit fields are not unexpectedly 
nulled out, which maintains data integrity but doesn't change any APIs.
   
   ### How was this patch tested?
   
   Added a new unit test `testMergeDoesNotOverwriteWithNull()` in 
`TestAuditInfo.java` that verifies:
   - Non-null values are preserved when merging with null values (with 
overwrite=true)
   - Non-null values from the source correctly overwrite existing values
   - The fix maintains backward compatibility for the non-overwrite case
   
   All existing tests pass, confirming no regression in functionality.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to