jbonofre opened a new pull request, #2898:
URL: https://github.com/apache/karaf/pull/2898

   ## Summary
   
   Fixes #2741.
   
   After a major JDK version change (e.g. JDK 11 -> 17), Karaf can become
   unresponsive to `etc/*.cfg` changes and deploy directory drops
   (`log:tail` shows nothing about the change). The reporter tracked this
   down to a stale bundle wiring persisted in `data/cache`: after
   restarting under the new JDK, the File Install bundle's cached wiring
   was missing wires to `org.osgi.service.cm` (Configuration Admin) and
   `org.osgi.service.log` (Log Service), so config/deploy directory
   monitoring silently stops working. Reverting to the previous JDK does
   not self-heal it, since the corrupted state is on disk, not
   JDK-dependent. The only documented workaround is stopping Karaf,
   wiping `data/`, and restarting.
   
   This is a resolver/bundle-cache staleness issue in the underlying OSGi
   framework (the system bundle's exported packages can differ between
   JDK major versions, and the cached wiring from a previous JDK is
   blindly reused). Rather than patch framework internals, this change
   makes Karaf detect the situation and clean up automatically:
   
   - `ConfigProperties` now records the JDK specification version
     (`java.specification.version`) used on the last start in
     `data/jdk_version`.
   - On startup, if the recorded version differs from the current one,
     the OSGi bundle cache (`org.osgi.framework.storage`, normally
     `data/cache`) is cleaned before the framework is created, forcing a
     full re-resolution instead of reusing stale wiring.
   - A normal restart on the same JDK (including patch upgrades, since
     only the specification version is compared) is unaffected.
   - The behavior can be disabled with
     `-Dkaraf.clean.cache.on.jdk.change=false` for anyone who wants to
     manage this themselves.
   
   ## Test plan
   
   - [x] Added `main/src/test/java/org/apache/karaf/main/util/UtilsTest.java`
         covering: first start (marker created, cache untouched), restart
         on the same JDK (cache untouched), and restart on a different
         JDK (cache cleaned, marker updated).
   - [x] `mvn -pl main test` passes (94 tests, 0 failures) under JDK 17.
   - [ ] Manual repro from the issue (start under JDK 11, switch to JDK
         17, confirm `org.ops4j.pax.logging.cfg` changes are still picked
         up) — not yet verified end-to-end with a packaged distribution.


-- 
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]

Reply via email to