Skip to content

Commit e366fde

Browse files
author
Gary Gregory
committed
Add missing IOUtils test
1 parent 83ac402 commit e366fde

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.net.Socket;
5050
import java.net.URI;
5151
import java.net.URL;
52+
import java.net.URLConnection;
5253
import java.nio.ByteBuffer;
5354
import java.nio.channels.FileChannel;
5455
import java.nio.channels.Selector;
@@ -441,6 +442,13 @@ public synchronized void close() throws IOException {
441442
});
442443
}
443444

445+
@Test
446+
public void testCloseURLConnection() {
447+
assertDoesNotThrow(() -> IOUtils.close((URLConnection) null));
448+
assertDoesNotThrow(() -> IOUtils.close(new URL("https://www.apache.org/").openConnection()));
449+
assertDoesNotThrow(() -> IOUtils.close(new URL("file:///").openConnection()));
450+
}
451+
444452
@Test
445453
public void testConstants() {
446454
assertEquals('/', IOUtils.DIR_SEPARATOR_UNIX);

0 commit comments

Comments
 (0)