|
20 | 20 | import java.io.ByteArrayOutputStream; |
21 | 21 | import java.io.CharArrayReader; |
22 | 22 | import java.io.CharArrayWriter; |
| 23 | +import java.io.Closeable; |
23 | 24 | import java.io.EOFException; |
24 | 25 | import java.io.File; |
25 | 26 | import java.io.FileInputStream; |
|
31 | 32 | import java.io.InputStreamReader; |
32 | 33 | import java.io.Reader; |
33 | 34 | import java.io.StringReader; |
| 35 | +import java.net.ServerSocket; |
| 36 | +import java.net.Socket; |
34 | 37 | import java.net.URI; |
35 | 38 | import java.net.URL; |
36 | 39 | import java.nio.channels.Selector; |
@@ -109,6 +112,40 @@ public void testCloseQuietlyNullSelector() { |
109 | 112 | IOUtils.closeQuietly(selector); |
110 | 113 | } |
111 | 114 |
|
| 115 | + public void testCloseableCloseQuietlyOnException() { |
| 116 | + IOUtils.closeQuietly(new Closeable() { |
| 117 | + public void close() throws IOException { |
| 118 | + throw new IOException(); |
| 119 | + } |
| 120 | + }); |
| 121 | + } |
| 122 | + |
| 123 | + public void testSocketCloseQuietlyOnException() { |
| 124 | + IOUtils.closeQuietly(new Socket() { |
| 125 | + public void close() throws IOException { |
| 126 | + throw new IOException(); |
| 127 | + } |
| 128 | + }); |
| 129 | + } |
| 130 | + |
| 131 | + public void testServerSocketCloseQuietlyOnException() throws IOException { |
| 132 | + IOUtils.closeQuietly(new ServerSocket() { |
| 133 | + public void close() throws IOException { |
| 134 | + throw new IOException(); |
| 135 | + } |
| 136 | + }); |
| 137 | + } |
| 138 | + |
| 139 | + public void testSocketCloseQuietly() { |
| 140 | + IOUtils.closeQuietly((Socket) null); |
| 141 | + IOUtils.closeQuietly(new Socket()); |
| 142 | + } |
| 143 | + |
| 144 | + public void testServerSocketCloseQuietly() throws IOException { |
| 145 | + IOUtils.closeQuietly((ServerSocket) null); |
| 146 | + IOUtils.closeQuietly(new ServerSocket()); |
| 147 | + } |
| 148 | + |
112 | 149 | public void testCloseQuietlySelector() { |
113 | 150 | Selector selector = null; |
114 | 151 | try { |
|
0 commit comments