paulrutter commented on PR #552: URL: https://github.com/apache/felix-dev/pull/552#issuecomment-5530989103
You're right, my earlier statement was wrong — `install()` returns early when `checkPlurlProtocol()` finds an installed plurl, so a second copy registers with the live router rather than replacing it. Nothing in the Felix registration needed changing. To answer your question: protocol-level delegation wouldn't help, because **every Felix framework instance uses the same `bundle:` protocol**. The owner is identified by the framework UUID in the URL host, so selection needs to see the URL. Implemented and split so the plurl part can be lifted on its own: - [`7f9938c`](https://github.com/apache/felix-dev/commit/7f9938ce896479908213d8c4f7895f9a831df71d) — `PlurlFactory` gains `default boolean shouldHandle(URL)` returning false; consulted during selection and delegated through `PlurlFactoryHolder` - [`5952c24`](https://github.com/apache/felix-dev/commit/5952c24986e4e2cfa813a05533221f7e479c0a69) — narrows it so only a factory that *claims* a URL can act, keeping the per-URL pinning - [`392c522`](https://github.com/apache/felix-dev/commit/392c52234cd7dfaed69346ae8b462655aa143afc) — Felix side: claim `bundle:` URLs by framework UUID `URLHandlersTest.urlHandlersWithClassLoaderIsolation` now passes. Three things worth knowing, all found by implementing it: 1. **The interface method alone is inert.** Selection happens in `parseURL`, where the JDK has set only `protocol` — `host` is populated *by* `parseURL` — so there's nothing to inspect, and that choice is then cached for the URL's lifetime. `PlurlFactoryHolder` also had to delegate the new method, or the default answers for every holder and never reaches a factory. 2. **Nothing changes unless a factory opts in.** My first attempt skipped the `urlToHandler` record while the URL was unparsed, which would have broken Equinox: `BundleResourceHandler` keeps mutable per-URL state (`bundleEntry`, cleared in `parseURL`, used as a fast path in `openConnection`) that assumes one handler per URL. `5952c24` instead records as before and lets only a claiming factory correct it once. Both Equinox factories declare only `shouldHandle(Class)`, so they never claim and behave identically. 3. **`shouldHandle(URL)` overloads `shouldHandle(Class)`**, making `shouldHandle(null)` ambiguous — it broke my own test compile. A distinct name would avoid that upstream. Separately: when no factory claims a URL, declining may be safer than selecting the first factory added, since framework A can be handed a URL naming framework B. Felix's UUID check makes that a clean failure; Equinox resolves only the bundle id against its bound container, so it would answer with its own resource. Happy to leave the fallback as-is if you'd rather. Glad to raise this as a plurl issue/PR, squashed however you prefer. -- 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]
