[SPARK-55682][CORE][SQL] ServiceLoader returned iterator may throw NoClassDefFoundError on hasNext()#54476
Closed
pan3793 wants to merge 2 commits intoapache:masterfrom
Closed
[SPARK-55682][CORE][SQL] ServiceLoader returned iterator may throw NoClassDefFoundError on hasNext()#54476pan3793 wants to merge 2 commits intoapache:masterfrom
NoClassDefFoundError on hasNext()#54476pan3793 wants to merge 2 commits intoapache:masterfrom
Conversation
…ClassDefFoundError on hasNext()
LuciferYang
reviewed
Feb 25, 2026
| } catch { | ||
| case t: Throwable => | ||
| logDebug(s"Failed to load built in provider.", t) | ||
| breakable { |
Contributor
There was a problem hiding this comment.
var keepLoading = true
while (keepLoading) {
try {
if (iterator.hasNext) {
providers += iterator.next
} else {
keepLoading = false
}
} catch {
case t: Throwable =>
logDebug(s"Failed to load built in provider.", t)
}
}
How about this? The Breaks feature will be deprecated in higher versions of Scala 3 (although it won't affect current code).
Member
Author
There was a problem hiding this comment.
The
Breaksfeature will be deprecated in higher versions of Scala 3
did not know that, let me change it to your suggested pattern
LuciferYang
approved these changes
Feb 25, 2026
Member
Author
|
thanks, merged to master for 4.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
JDK 24 introduces a behavior change on
ServiceLoader's returned iterator,iterator.hasNext()might throwNoClassDefFoundError, which previously only happened oniterator.next(). See more details at OpenJDKbug report JDK-8350481
Another issue is even the Javadoc of
ServiceLoadersaybut it actually might throw
NoClassDefFoundError. See more details at OpenJDK bug report JDK-8196182Why are the changes needed?
Enable Java 25 support.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Changes in
HadoopDelegationTokenManagerare covered by UT, other 2 places are not, need to review carefully.Before
After
A similar issue was fixed in Hadoop too, see HADOOP-19821. I created a simple project to help reviewers better understand this issue and solution.
Was this patch authored or co-authored using generative AI tooling?
No.