Add missing IOUtils test
import java.net.Socket;
import java.net.URI;
import java.net.URL;
+import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.Selector;
@@ -441,6 +442,13 @@ public synchronized void close() throws IOException {
});
}
+ @Test
+ public void testCloseURLConnection() {
+ assertDoesNotThrow(() -> IOUtils.close((URLConnection) null));
+ assertDoesNotThrow(() -> IOUtils.close(new URL("https://www.apache.org/").openConnection()));
+ assertDoesNotThrow(() -> IOUtils.close(new URL("file:///").openConnection()));
+ }
+
@Test
public void testConstants() {
assertEquals('/', IOUtils.DIR_SEPARATOR_UNIX);
