Skip to content

[SPARK-36750][CORE][SQL][MLLIB][YARN] Replace the Guava API with java.util.Objects API with the same semantics#33991

Closed
LuciferYang wants to merge 3 commits intoapache:masterfrom
LuciferYang:SPARK-36750
Closed

[SPARK-36750][CORE][SQL][MLLIB][YARN] Replace the Guava API with java.util.Objects API with the same semantics#33991
LuciferYang wants to merge 3 commits intoapache:masterfrom
LuciferYang:SPARK-36750

Conversation

@LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Sep 14, 2021

What changes were proposed in this pull request?

Java 8 provides the java.util.Objects, this pr it to replace some Guava API usages with the same semantics, the replacement rules are as follows:

  1. Preconditions.checkNotNull -> Objects.requireNonNull

Guava

public static <T> T checkNotNull(T reference,
      @Nullable String errorMessageTemplate,
      @Nullable Object... errorMessageArgs) {
    if (reference == null) {
      // If either of these parameters is null, the right thing happens anyway
      throw new NullPointerException(
          format(errorMessageTemplate, errorMessageArgs));
    }
    return reference;
  }

java.util.Objects

    public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
        if (obj == null)
            throw new NullPointerException(messageSupplier.get());
        return obj;
    }
  1. Objects.hashCode -> j.u.Objects.hash

Guava

  public static int hashCode(@Nullable Object... objects) {
    return java.util.Arrays.hashCode(objects);
  }

java.util.Objects

    public static int hash(Object... values) {
        return java.util.Arrays.hashCode(values);
    }
  1. Objects.equal -> j.u.Objects.equals

Guava

  public static boolean equal(@Nullable Object a, @Nullable Object b) {
    return a == b || (a != null && a.equals(b));
  }

java.util.Objects

    public static boolean equals(Object a, Object b) {
        return (a == b) || (a != null && a.equals(b));
    }

Why are the changes needed?

Reduce dependence on Guava API because Spark still use Guava 14.0.1.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass the Jenkins or GitHub Action

@LuciferYang LuciferYang changed the title [SPARK-36750][CORE] Replace the Guava API with j.u.Objects API with the same semantics [SPARK-36750][CORE][SQL][MLLIB] Replace the Guava API with j.u.Objects API with the same semantics Sep 14, 2021
@LuciferYang LuciferYang changed the title [SPARK-36750][CORE][SQL][MLLIB] Replace the Guava API with j.u.Objects API with the same semantics [SPARK-36750][CORE][SQL][MLLIB][YARN] Replace the Guava API with j.u.Objects API with the same semantics Sep 14, 2021
@LuciferYang LuciferYang changed the title [SPARK-36750][CORE][SQL][MLLIB][YARN] Replace the Guava API with j.u.Objects API with the same semantics [SPARK-36750][CORE][SQL][MLLIB][YARN] Replace the Guava API with java.util.Objects API with the same semantics Sep 14, 2021
@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47747/

@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47747/

@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47751/

@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47751/

@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Test build #143248 has finished for PR 33991 at commit 7d0a912.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 14, 2021

Test build #143245 has finished for PR 33991 at commit 551c1ec.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@github-actions
Copy link

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

@github-actions github-actions bot added the Stale label Dec 24, 2021
@github-actions github-actions bot closed this Dec 25, 2021
@LuciferYang LuciferYang deleted the SPARK-36750 branch October 22, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments