sharanggupta commented on code in PR #575:
URL: https://github.com/apache/felix-dev/pull/575#discussion_r4280004933


##########
framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java:
##########
@@ -303,6 +304,7 @@ protected URLConnection openConnection(URL url) throws 
IOException
         }
         catch (Exception ex)
         {
+            rethrowIOException(ex);

Review Comment:
   Thanks, you're right, and the PR description promised exactly that case. 
Fixed in 22321201ce: `invoke()` now catches the `InvocationTargetException` and 
throws its target exception, as a direct call would. The proxy then propagates 
the declared `IOException` of `openConnection` instead of wrapping it in an 
`UndeclaredThrowableException`. 
`handlerServiceOfAnotherClassLoaderPropagatesIOException` builds the proxy the 
way `getStreamHandlerService()` does, with a service that is not a 
`URLStreamHandlerService`. It fails with `UndeclaredThrowableException` before 
this commit.



##########
framework/src/test/java/org/apache/felix/framework/URLHandlersStreamHandlerProxyTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.apache.felix.framework.util.SecureAction;
+import org.junit.jupiter.api.Test;
+
+/**
+ * An {@link IOException} thrown by a stream handler invoked through 
reflection is propagated
+ * unchanged (FELIX-6861).
+ */
+class URLHandlersStreamHandlerProxyTest

Review Comment:
   Added `openConnectionWithProxyPropagatesIOExceptionOfHandlerService` for the 
`URLStreamHandlerService` + `Proxy` branch in 22321201ce. It uses a stub 
extending `AbstractURLStreamHandlerService` with a public `openConnection(URL, 
Proxy)` as the built-in handler. The extension-manager branch is still not 
covered: it needs a framework whose `ExtensionManager` instance is reachable 
through the static `m_extensionManager` field, which this unit test does not 
set up. If you know an existing test that starts one, I can add a case there.



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