Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2164][#2166] improvement: enable MutablePublicArray and ReferenceEquality error-prone #2511

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

coolderli
Copy link
Contributor

@coolderli coolderli commented Mar 12, 2024

What changes were proposed in this pull request?

  1. MutablePublicArray
    MutablePublicArray aims to avoid public static final List<T>, because it can be modified outside. See more details at https://errorprone.info/bugpattern/MutablePublicArray.

There are two ways to fix this problem:

  • Refactor the array to an ImmutableList.
  • Make the array private and add a public method that returns a copy of the private array.

Since MutablePublicArray has been fixed at #2171, we enable the check in this MR.

  1. ReferenceEquality
    ReferenceEquality aims to use reference equality instead of value equality for reference objects.
    There are some ways to fix this problem:
  • use .equals() instead of ==
  • use Objects.equals() if there is a null

See more details at https://errorprone.info/bugpattern/ReferenceEquality.

In this MR, we suppress this check at com.datastrato.gravitino.catalog.lakehouse.iceberg.converter.ToIcebergType#struct and com.datastrato.gravitino.lock.LockManager#createTreeLock. In there places, we'd better use reference to compare the root node.

Why are the changes needed?

Does this PR introduce any user-facing change?

  • no

How was this patch tested?

  • ./gradlew build

@coolderli
Copy link
Contributor Author

@yuqi1129 @qqqttt123 Could you please help review this? Thanks.

@jerryshao jerryshao requested review from yuqi1129 and qqqttt123 March 12, 2024 06:14
Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

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

It's okay with me.

@@ -649,4 +649,11 @@ void testDeadLockChecker() throws InterruptedException, ExecutionException {
service.take().get();
}
}

@Test
public void testMockRootTreeLock() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to add this test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qqqttt123 I can remove it. I add it to validate https://github.com/datastrato/gravitino/pull/2511/files#diff-2144813a8300501a572d32e9f24651ab50594709644c031e983ac05a38bdc519R233.
if we replace == with .equals(), this unit test will failed. Do you think we need this?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I got it.

@qqqttt123 qqqttt123 merged commit 5e23ddf into apache:main Mar 12, 2024
12 checks passed
@qqqttt123
Copy link
Contributor

Thanks @coolderli @yuqi1129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants