sharanggupta opened a new pull request, #575: URL: https://github.com/apache/felix-dev/pull/575
Fixes [FELIX-6861](https://issues.apache.org/jira/browse/FELIX-6861). `URLHandlersStreamHandlerProxy.openConnection(URL)` and `openConnection(URL, Proxy)` invoke a stream handler that is not a `URLStreamHandlerService` of the framework class loader (the built-in handler, or a handler from another class loader) through reflection. `Method.invoke()` wraps an `IOException` thrown by the handler in an `InvocationTargetException`, which the generic `catch (Exception)` then wrapped in an `IllegalStateException("Stream handler unavailable due to: null")`. So `URL.openConnection()` failures such as `FileNotFoundException` escaped `catch (IOException)` blocks, unlike with a direct invocation of the handler. A small `rethrowIOException()` helper now rethrows the handler's `IOException` (the cause of the `InvocationTargetException`) on the four reflective paths: - the reflective invocation in `openConnection(URL)` and in `openConnection(URL, Proxy)`; - the extension handler branch of `openConnection(URL)`, which wrapped it in a new `IOException` without the original type or stack; - the reflective call of `openConnection(URL, Proxy)` on a `URLStreamHandlerService`, which did the same. Other invocation failures keep their current handling (`IllegalStateException` or `IOException` as before). **Test:** `URLHandlersStreamHandlerProxyTest` opens a connection through the proxy with a built-in handler that throws a `FileNotFoundException`, with and without a `Proxy`, and checks that the same exception instance is thrown; a handler throwing an `UnsupportedOperationException` is still reported as an `IllegalStateException`. On `master` the first two fail with the `IllegalStateException` above; with the change all three pass, and `mvn verify` of the framework module passes locally. -- 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]
