Skip to content

LDEV-6627 load Require-Bundle bundles first, keep the failed download as cause - #15

Merged
michaeloffner merged 1 commit into
mainfrom
LDEV-6627-require-bundle-and-cause
Nov 20, 2026
Merged

michaeloffner merged 1 commit into
mainfrom
LDEV-6627-require-bundle-and-cause

Conversation

@michaeloffner

Copy link
Copy Markdown
Contributor

Two fixes found by the Lucee tests with the OSGi extension (lucee/Lucee#3849).

Require-Bundle is loaded first
A bundle like `org.lucee.janino` has `Import-Package: org.codehaus.commons.compiler` and `Require-Bundle: org.lucee.janinocc`. The resolver reports the missing package first, no bundle is known for that package, and the load failed (`no bundle known that exports the package [org.codehaus.commons.compiler]`, Lucee `test/general/Janino.cfc`). Now the non optional `Require-Bundle` entries of a jar (with their `bundle-version` range) are loaded before the jar is installed, in both `load()` overloads. A required bundle that cannot be loaded is ignored there and reported by the resolver when the bundle is started, as before. `system.bundle` is skipped, a thread local guards against cycles.

The failed download is the cause of the error
`download()` only wrapped `BundleException` and `RuntimeException` of the URL lookup, the `IOException` ("no URL found for bundle ...") went out without cause. It is wrapped as well now (Lucee `test/tickets/LDEV6313.cfc` expects `e.cause`).

New `RequireBundleTest`: parsing of `Require-Bundle`, a bundle that imports a package of its required bundle (fails with exactly the Janino error without the change), and the cause of a failed download.

@GianTschingt GianTschingt 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.

Looks good, both fixes do what #3849 needs. I checked org.lucee:janino:3.1.9: it has Require-Bundle: org.lucee.janinocc;bundle-version=3.1.9, so loading the required bundle first resolves org.codehaus.commons.compiler. The URL lookup error is now the cause, which is what LDEV6313 checks.

A few points, the first one I'd fix here or right after:

  1. Require-Bundle is only read when a jar gets installed (load() at L448/L478). A bundle that is already installed returns early, and with storage.clean=none it stays installed across restarts. So an install where org.lucee.janino is already in INSTALLED state (e.g. from 1.0.0.1-BETA) still fails after the upgrade, and a temporary download failure of janinocc stays stuck until restart. The package branch of loadMissing (L646) and install(File, boolean) (L774) skip it too. Core reads the requirements from the installed bundle when it starts it (getRequiredBundles(bundle) via BundleRevision). Loading the osgi.wiring.bundle requirements of the bundle when startIfNecessary fails in loadAndStart would cover all of these.
  2. loadRequiredBundles drops the failures (L416). The resolver then names the missing package first, so the user gets "no bundle known that exports the package [org.codehaus.commons.compiler]" instead of the real download error. Could they be added to problems?
  3. Only the URL lookup is wrapped. An IOException while streaming the download (L497-506) still comes through without the bundle name or a cause.
  4. Minor: required bundles are installed but not started (core started them), the wrapped message repeats the bundle name, and failedDownloadIsTheCauseOfTheError needs network access.

#3849 still bundles 1.0.0.1-BETA, so after this is merged we need a new BETA published and #3849 bumped to it to get it green.

@michaeloffner
michaeloffner merged commit f9d2df3 into main Nov 20, 2026
5 checks passed
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