[SPARK-54049][BUILD][4.0] Shade com.google.thirdparty package to fix Guava class conflicts in spark 4.0 #52869
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport #52767 to Spark 4.0 branch
We upgraded Guava from 14.0.1 to 30+ in spark 4.0 . Guava 33.4.0 used in Spark 4 consists of two main packages:
com.google.commoncom.google.thirdpartyPrior to this PR, only the
com.google.commonpackage was shaded into the spark-network-common jar, while classes undercom.google.thirdpartyremained unshaded in the spark-network-common jar. This partial shading causes classloading conflicts and runtime errors when a downstream project depends on both Spark and its own version of Guava.Eg: calls to guava class
com.google.common.net.InternetDomainNamefails with the following error:Root Cause:
com.google.common.net.InternetDomainNameuses classes fromcom.google.thirdparty.publicsuffix.The classloader resolves
com.google.common.net.InternetDomainNamefrom the downstream Guava jar, whilecom.google.thirdparty.publicsuffix.PublicSuffixPatternsis loaded from Spark 4.x Guava classes, leading to binary incompatibility.Example diagnostic:
What changes were proposed in this pull request?
This PR ensures package
com.google.thirdpartyis also shaded and isolated under the sparkproject namespace in Spark, preventing downstream class conflicts and runtime errors.Why are the changes needed?
These changes are necessary to prevent runtime errors and class conflicts for downstream projects that depend on both Spark and Guava by restoring proper isolation of shaded Guava classes in spark
Does this PR introduce any user-facing change?
No
How was this patch tested?
No new test cases added; used existing UT and IT.
Was this patch authored or co-authored using generative AI tooling?
No