ponziani opened a new pull request, #2978: URL: https://github.com/apache/karaf/pull/2978
Fixes [KARAF-5784](https://issues.apache.org/jira/browse/KARAF-5784) and [KARAF-7163](https://issues.apache.org/jira/browse/KARAF-7163). ## Problem A feature whose version has a leading zero in a numeric segment (e.g. `1.0.01` or `1.01.1-SNAPSHOT`) gets installed: its bundles are deployed and running. Karaf still reports the feature as not installed / `Uninstalled`, without any error in the log: - KARAF-7163: a boot feature with such a version never reaches state `Started`. - KARAF-5784: a feature deployed through a KAR does not show up as installed and started. ## Cause Feature ids are built in two different ways: - `Feature.getId()` (and `FeaturesServiceImpl.normalize()`) keep the version string as written: `f/1.0.01`. - The deployment state (`State.installedFeatures` / `stateFeatures`) is keyed by `ResourceUtils.getFeatureId(Resource)`. That method uses the OSGi `Version` of the feature resource, which is normalized: `f/1.0.1`. The two ids never match, so: - `isInstalled()` / `getState()` don't find the feature; - `feature:start` / `feature:stop` (`updateFeaturesState`) are silently ignored; - the `Deployer` doesn't install (or delete) the feature's configurations and libraries. Resolution itself is not affected, because requirements use version ranges. ## Fix Feature ids are now normalized the OSGi way everywhere they are compared with the deployment state: - `ResourceUtils.getFeatureId(String, String)` and `normalizeFeatureId(String)` produce the same form as `getFeatureId(Resource)`. - `FeaturesServiceImpl.normalize()` uses that form, which fixes `isInstalled()` and `getState()`. - `Deployer` uses it for `featuresById`, for requested state changes, and when installing configurations and libraries. The persisted state already used the normalized form, so existing installations need no migration. ## Tests - New test `FeaturesServiceImplTest#testInstallAndStopFeatureWithLeadingZeroInVersion` installs a `1.0.01` feature. It checks that the feature is installed and `Started`, then stops it through its own id. Without the fix the test fails with `Feature f/1.0.01 not installed.` - `mvn -pl features/core install`: 141 tests, 0 failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
