Skip to content

[SPARK-35609][BUILD] Add style rules to prohibit to use a Guava's API which is incompatible with newer versions #32740

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

Closed
wants to merge 1 commit into from

Conversation

sarutak
Copy link
Member

@sarutak sarutak commented Jun 2, 2021

What changes were proposed in this pull request?

This PR adds rules to checkstyle.xml and scalastyle-config.xml to avoid introducing Objects.toStringHelper a Guava's API which is no longer present in newer Guava.

Why are the changes needed?

SPARK-30272 (#26911) replaced Objects.toStringHelper which is an APIs Guava 14 provides with commons.lang3 API because Objects.toStringHelper is no longer present in newer Guava.
But toStringHelper was introduced into Spark again and replaced them in SPARK-35420 (#32567).
I think it's better to have a style rule to avoid such repetition.

SPARK-30272 replaced some APIs aside from Objects.toStringHelper but Objects.toStringHelper seems to affect Spark for now so I add rules only for it.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

I confirmed that lint-java and lint-scala detect the usage of toStringHelper and let the lint check fail.

$ dev/lint-java
exec: curl --silent --show-error -L https://downloads.lightbend.com/scala/2.12.14/scala-2.12.14.tgz
Using `mvn` from path: /opt/maven/3.6.3//bin/mvn
Checkstyle checks failed at following occurrences:
[ERROR] src/main/java/org/apache/spark/network/protocol/OneWayMessage.java:[78] (regexp) RegexpSinglelineJava: Avoid using Object.toStringHelper. Use ToStringBuilder instead.

$ dev/lint-scala 
Scalastyle checks failed at following occurrences:
[error] /home/kou/work/oss/spark/core/src/main/scala/org/apache/spark/rdd/RDD.scala:93:25: Avoid using Object.toStringHelper. Use ToStringBuilder instead.
[error] Total time: 25 s, completed 2021/06/02 16:18:25

@github-actions github-actions bot added the BUILD label Jun 2, 2021
@SparkQA
Copy link

SparkQA commented Jun 2, 2021

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

@SparkQA
Copy link

SparkQA commented Jun 2, 2021

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

@SparkQA
Copy link

SparkQA commented Jun 2, 2021

Test build #139205 has finished for PR 32740 at commit 0252b1e.

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

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

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

Seems reasonable to prohibit this particular method - we dont' use it anymore in the code now?

@sarutak
Copy link
Member Author

sarutak commented Jun 3, 2021

I think, we have no more use of Objects.toStringHelper for now.
lint-java and lint-scala passed and I also confirmed with the following commands.

build/mvn -Phive -Phive-thriftserver -Pkubernetes -Pyarn -Pmesos -Pdocker-integration-tests -Pkubernetes-integration-tests -Pspark-ganglia-lgpl -Pkinesis-asl -Phadoop-cloud checkstyle:check | grep ERROR

build/sbt -Phive -Phive-thriftserver -Pkubernetes -Pyarn -Pmesos -Pdocker-integration-tests -Pkubernetes-integration-tests -Pspark-ganglia-lgpl -Pkinesis-asl -Phadoop-cloud scalastyle test:scalastyle

@sarutak sarutak closed this in c532f82 Jun 3, 2021
@sarutak
Copy link
Member Author

sarutak commented Jun 3, 2021

Merged to master.

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

Successfully merging this pull request may close these issues.

3 participants