ppkarwasz commented on code in PR #799:
URL: https://github.com/apache/commons-io/pull/799#discussion_r2429989218


##########
src/main/java/org/apache/commons/io/channels/CloseShieldChannel.java:
##########
@@ -66,10 +69,32 @@ public static <T extends Channel> T wrap(final T channel) {
         // Collect only Channel sub-interfaces.
         final Set<Class<?>> set = collectChannelInterfaces(channel.getClass(), 
new LinkedHashSet<>());
         // fallback to root surface
-        return (T) Proxy.newProxyInstance(channel.getClass().getClassLoader(), 
// use delegate's loader
+        return (Channel) 
Proxy.newProxyInstance(channel.getClass().getClassLoader(), // use delegate's 
loader
                 set.isEmpty() ? new Class<?>[] { Channel.class } : 
set.toArray(EMPTY), new CloseShieldChannelHandler(channel));
     }
 
+    /**
+     * Wraps a channel to shield it from being closed.
+     *
+     * @param channel The underlying channel to shield, not {@code null} and 
must implement {@code type}.
+     * @param type    The interface the returned proxy must implement;
+     *                the proxy will also implement all other {@link Channel} 
sub-interfaces that the delegate implements.
+     * @param <T>     A type that extends {@link Channel}.
+     * @return A proxy that shields {@code close()} and enforces closed 
semantics on other calls.
+     * @throws IllegalArgumentException if {@code type} is not an interface or 
if {@code channel} does not implement {@code type}.
+     */
+    @SuppressWarnings({ "unchecked", "resource" }) // caller closes

Review Comment:
   IDEA says that both are not needed, so I suppose this is really 
IDE-dependent.



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