Skip to content

fix: warn about bndlib header validation changes when upgrading maven-bundle-plugin (#14164) - #14167

Open
gnodet wants to merge 3 commits into
apache:masterfrom
gnodet:fix/bundle-plugin-large-version-gap
Open

gnodet wants to merge 3 commits into
apache:masterfrom
gnodet:fix/bundle-plugin-large-version-gap

Conversation

@gnodet

@gnodet gnodet commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Emit a warning when upgrading maven-bundle-plugin to 5.1.1 (bndlib 5.x), so users know to check their OSGi bundle headers if the build fails after the upgrade.

Background — why the upgrade was introduced

PluginUpgradeStrategy added maven-bundle-plugin → 5.1.1 in PR #13001 (Sept 2026) to fix a real breakage on JDK 17.0.13+:

  • FELIX-6259 / JDK-8259535: bndlib < 5.1.0 has a bug in Jar.putResource() — it modifies a TreeMap from inside its own computeIfAbsent() callback. JDK 17.0.13 backported stricter CME detection from JDK 21, so this now reliably throws ConcurrentModificationException. Since Maven 4 requires JDK 17+, every project using an old BND plugin breaks.
  • 5.1.1 is the minimum version that fixes FELIX-6259 while still supporting JDK 11+ at runtime (bndlib 7.x / plugin 6.0.0 bumped the runtime requirement to JDK 17).
  • Affected projects at the time of introduction: geronimo-health, geronimo-metrics, geronimo-opentracing, geronimo-config, geronimo-jcache-simple, aries-journaled-events, aries-tx-control.

Root Cause (this PR)

The upgrade from plugin 4.2.1 → 5.1.1 crosses one bndlib major version boundary (4.x → 5.x), which introduced stricter OSGi header validation. Projects with edge-case headers (e.g. empty Bundle-NativeCode) that bndlib 4.x accepted may fail after the upgrade.

The upgrade was applied silently with no indication of the validation change.

Fix

Emit a warning on every maven-bundle-plugin upgrade explaining that the new version uses a different bndlib major version and what to do if the build fails:

[WARNING] Upgrading org.apache.felix:maven-bundle-plugin from 2.3.7 to 5.1.1: this upgrade
crosses one or more bndlib major version boundaries, each of which introduced stricter OSGi
header validation. If the build fails after the upgrade, check your OSGi bundle headers for
compatibility with bndlib 5.x (e.g. empty Bundle-NativeCode values are no longer accepted).

The upgrade itself is still applied — skipping it would leave the FELIX-6259 CME unfixed, which is worse than a header validation failure the user can fix. The warning is informational only.

Tests

5 new unit tests covering 2.3.7, 2.4.0, 3.5.0, 4.2.1, and a property-based version — all upgraded to 5.1.1 with a warning verified where relevant. 952 tests pass.

Fixes #14164


Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet

@gnodet
gnodet force-pushed the fix/bundle-plugin-large-version-gap branch 2 times, most recently from 16cb3b9 to 408a732 Compare November 28, 2026 16:45
…-bundle-plugin (apache#14164)

When upgrading maven-bundle-plugin to 5.1.1 (bndlib 7.x), every bndlib
major version introduced stricter OSGi header validation. Projects with
edge-case headers may encounter build failures after the upgrade.

The upgrade is still applied — it is required to fix FELIX-6259
(ConcurrentModificationException on JDK 17+) — but a warning is emitted
so users know to check their OSGi bundle headers if the build fails after
the upgrade (e.g. empty Bundle-NativeCode values are no longer accepted
by bndlib 7.x).

Fixes apache#14164
@gnodet
gnodet force-pushed the fix/bundle-plugin-large-version-gap branch from 408a732 to 2499a92 Compare November 28, 2026 18:00
@gnodet
gnodet marked this pull request as ready for review November 28, 2026 19:11
@gnodet gnodet added bug Something isn't working backport-to-4.0.x labels Nov 28, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fix is correct: warn-and-upgrade is the right approach (skipping would leave users on a version with a known ConcurrentModificationException on JDK 17+). One minor gap in test coverage. Also: the PR title says 'skip' but the code actually warns — suggest updating the title.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

…ion in property test

- Comment and warning message incorrectly referenced 'bndlib 7.x' (5.1.1 uses bndlib 5.x;
  7.x only arrived with plugin 6.0.0+)
- Warning said 'spans multiple bndlib major versions' but the upgrade from 4.x to 5.x
  crosses only one major version boundary; reworded to 'one or more bndlib major version
  boundaries' which is accurate for all upgrade origins
- shouldUpgradeBundlePluginFromPropertyWhenBndlib2x now verifies the warning is emitted
  (was missing; flagged by gnodet-bot review)
@gnodet gnodet changed the title fix: skip maven-bundle-plugin upgrade from bndlib 2.x to avoid OSGi header regressions (#14164) fix: warn about bndlib header validation changes when upgrading maven-bundle-plugin (#14164) Dec 2, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following up on my earlier review — the previous finding is now fully addressed. ✅

The missing warning assertion in shouldUpgradeBundlePluginFromPropertyWhenBndlib2x has been added (verify(context.logger, atLeastOnce()).warn(...) now covers the property-based upgrade path), and the bndlib version references in the comment and warning message have been corrected ("one or more bndlib major version boundaries" is accurate for all upgrade origins).

No new issues in this follow-up commit. LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

The PluginUpgradeStrategyTest.java file exceeds the 2000-line limit
(2005 lines) after adding bundle-plugin upgrade warning tests.
Follow the same pattern as maven-impl to suppress this check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-4.0.x bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mvnup: maven-bundle-plugin upgrade to 5.1.1 too aggressive for legacy OSGi projects (bndlib 2.x to 7.x breaking changes)

2 participants