Skip to content

Handle invalid OSGi versions in FeatureReq and Subsystem - #3139

Merged
jbonofre merged 1 commit into
apache:mainfrom
jbonofre:fix-feature-req-subsystem-invalid-version
Nov 20, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
jbonofre:fix-feature-req-subsystem-invalid-version

Conversation

@jbonofre

Copy link
Copy Markdown
Member

Follow-up to #2978 addressing the two remaining places noted in the review comments where a feature with an unparseable OSGi version (e.g. 1.0.0.beta+1) still caused IllegalArgumentException:

Problem

  1. FeatureReq:
    • Calling getFeature("bad", "1.0.0.beta+1") or listRequiredFeatures() / isRequired(bad) threw IllegalArgumentException in FeatureReq.exactVersion.
    • When a feature with an invalid version shared a name with a valid feature (e.g. f/1.0.0.beta+1 next to f/1.0.0), FeatureReq.getLatestFeature iterated all versions of f and threw IllegalArgumentException in VersionTable.getVersion, breaking getFeature("f") and getFeature("f", "1.0.0").
  2. Subsystem:
    • Subsystem.doBuild parsed VersionTable.getVersion(feature.getVersion()) for every same-name feature in allFeatures.get(name), so an invalid f/1.0.0.beta+1 next to f/1.0.0 broke installing f.

Changes

  • FeatureReq:
    • Fall back to storing rawVersion when exactVersion cannot parse a version as an OSGi VersionRange, allowing getFeature("bad", "1.0.0.beta+1"), isRequired(), and listRequiredFeatures() to work without throwing.
    • Skip unparseable versions in getLatestFeature() when evaluating OSGi version ranges so same-name valid features remain selectable.
  • Subsystem:
    • Catch IllegalArgumentException from VersionTable.getVersion(feature.getVersion()) in doBuild() and skip the unparseable feature with a warning log, since it cannot be represented as a Subsystem or FeatureResource anyway.
  • Tests:
    • Updated FeaturesServiceImplTest#testFeatureWithInvalidVersionDoesNotBreakOtherFeatures to verify listRequiredFeatures(), isRequired(), and getFeature("bad", "1.0.0.beta+1").
    • Added FeaturesServiceImplTest#testFeatureWithSameNameAndInvalidVersionDoesNotBreakInstall (with invalidversion/same-name.xml).
    • Added SubsystemTest#testIgnoreSameNameFeatureWithInvalidVersion.

Testing

  • JAVA_HOME=$(/usr/libexec/java_home -v 21) mvn -pl features/core -am test: features/core passed (157 tests, 0 failures, 0 errors, 2 pre-existing skipped; FeaturesServiceImplTest: 19 tests, 0 failures, 0 errors).

Follow-up to apache#2978 for the two remaining places where unparseable OSGi feature versions caused IllegalArgumentException:

- FeatureReq: fall back to raw version matching/formatting when exactVersion cannot parse a version as an OSGi VersionRange (e.g. getFeature("bad", "1.0.0.beta+1") and listRequiredFeatures()/isRequired()), and skip unparseable versions in getLatestFeature() instead of failing on same-name valid features.
- Subsystem: skip same-name features whose version cannot be parsed by VersionTable.getVersion() during subsystem building, with a warning log, so an invalid version next to a valid one does not break installing the valid feature.
- Add tests in FeaturesServiceImplTest and SubsystemTest covering exact lookup, listRequiredFeatures/isRequired, and installing a valid feature alongside a same-name invalid-version feature.
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Test Results

1 112 files  ±0  1 112 suites  ±0   1h 25m 50s ⏱️ - 2m 27s
1 365 tests +2  1 233 ✅ +3  132 💤 ±0  0 ❌  - 1 
5 460 runs  +8  4 930 ✅ +9  530 💤 ±0  0 ❌  - 1 

Results for commit c8e3cf6. ± Comparison against base commit 0d48ef9.

♻️ This comment has been updated with latest results.

@jbonofre
jbonofre merged commit b75cae0 into apache:main Nov 20, 2026
16 of 17 checks passed
@jbonofre
jbonofre deleted the fix-feature-req-subsystem-invalid-version branch November 20, 2026 20:24
@holgerfriedrich

Copy link
Copy Markdown
Contributor

@jbonofre FYI: I have tested on top of this PR, b75cae0, creating and running full openHAB distributions, both with Java 21 and 25 (classed compiled to Java 25). I did not find any unexpected errors. CI tests are still (re)running.
I think we are good to go! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants