iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Review new ImmutablesReferenceEquality error-prone check

Open findepi opened this issue 2 years ago • 8 comments

ImmutablesReferenceEqualityis a recently added error-prone check (https://github.com/apache/iceberg/pull/10788). Figure out whether we adjust the code or suppress the check permanently

findepi avatar Aug 02 '24 12:08 findepi

Hi team, may I take a look on this issue?

danielhumanmod avatar Aug 14 '24 04:08 danielhumanmod

sure, go for it!

findepi avatar Aug 15 '24 17:08 findepi

Hi @findepi , based on my investigation, the current status regarding the usage of ImmutablesReferenceEquality is as follows:

Currently, ImmutablesReferenceEquality is only triggered in line 119 of BaseViewOpertaions.java

// if the metadata is not changed, return early
    if (base == metadata) {
      LOG.info("Nothing to commit.");
      return;
    }

According to PR #10899 ,this comparison is intentionally performing a reference equality check. Therefore, the @SuppressWarnings("ImmutablesReferenceEquality") here is reasonable.

Considering for most cases we don't encourage reference equality check for immutable objects, we should consider keep this error-prone check. For cases where reference equality is indeed necessary, contributors can use @SuppressWarnings("ImmutablesReferenceEquality") to bypass the warning. However, contributors should explain the necessity of the reference equality check, and all instances of @SuppressWarnings should be carefully reviewed during code reviews.

danielhumanmod avatar Aug 17 '24 05:08 danielhumanmod

Additionally, I do notice that there are several DangerousJavaDeserialization warning in our code, do we have a plan to do some investigation on that?

danielhumanmod avatar Aug 17 '24 05:08 danielhumanmod

Hi @findepi , I’ve shared an initial conclusion in my previous comment regarding the usage of ImmutablesReferenceEquality. Do you think any further action is needed on this issue, or should we involve additional reviewers?

Thanks for your input!

danielhumanmod avatar Sep 03 '24 00:09 danielhumanmod

thanks for your insights @danielhumanmod !

there are several DangerousJavaDeserialization warning in our code, do we have a plan to do some investigation on that?

There is a separate issue about this: https://github.com/apache/iceberg/issues/10853

Currently, ImmutablesReferenceEquality is only triggered in line 119 of BaseViewOpertaions.java

if this is the only place, then yes it makes sense to enable the check and just suppress in this place.

And yes, it's intentional.

However, contributors should explain the necessity of the reference equality check, and all instances of @SuppressWarnings should be carefully reviewed during code reviews.

@danielhumanmod good point. Suppression should be last resort and code-commented.

findepi avatar Sep 03 '24 07:09 findepi

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

github-actions[bot] avatar Mar 03 '25 00:03 github-actions[bot]

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

github-actions[bot] avatar Mar 17 '25 00:03 github-actions[bot]