Detect BND computeIfAbsent CME and provide actionable diagnostic - #13000
Closed
gnodet wants to merge 1 commit into
Closed
Detect BND computeIfAbsent CME and provide actionable diagnostic#13000gnodet wants to merge 1 commit into
gnodet wants to merge 1 commit into
Conversation
When maven-bundle-plugin 4.x or bnd-maven-plugin 4.x throws a ConcurrentModificationException during plugin execution, Maven now detects the known BND bug (FELIX-6259) and provides a clear error message with upgrade instructions instead of a cryptic CME. Root cause: BND's Jar.putResource() uses TreeMap.computeIfAbsent() with a mapping function that modifies the same TreeMap (adding ancestor directories). JDK 17.0.13+ backported CME detection for TreeMap.computeIfAbsent() (JDK-8259535), which correctly rejects this self-modification pattern. Since Maven 4 requires JDK 17+, all Maven 4 users hit this with old BND versions (bndlib < 5.1.0). Fixes apache#12987 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
Closing in favor of the mvnup approach — upgrading the plugin is the right fix, not adding diagnostics to maven-core. |
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.
Summary
Fixes #12987 —
ConcurrentModificationExceptionin BND/maven-bundle-plugin during dependency resolution under Maven 4.Root Cause
BND's
Jar.putResource()(bndlib ≤ 5.0.0) usesTreeMap.computeIfAbsent()with a mapping function that modifies the same TreeMap — it adds ancestor directory entries inside the mapping function:This violates the
computeIfAbsent()contract. JDK 17.0.13+ backported explicit CME detection forTreeMap.computeIfAbsent()(JDK-8259535), which correctly rejects this self-modification pattern. Since Maven 4 requires JDK 17+, all Maven 4 users hit this with old BND versions.The bug was fixed in bndlib 5.1.0 (FELIX-6259, BND PR #3904).
What This PR Does
ConcurrentModificationExceptionspecifically inDefaultBuildPluginManager.executeMojo()aQute.bnd.osgi.Jar.putResource)maven-bundle-pluginto 5.1.9+ orbnd-maven-pluginto 6.0.0+computeIfAbsent()issues on newer JDKsBefore (cryptic error)
After (actionable diagnostic)
Affected Projects
All 7 projects identified in #12987 use old BND versions (bndlib 4.0.0–4.3.0) that predate the fix:
Test plan
🤖 Generated with Claude Code