MCPcopy
hub / github.com/google/guava / close

Method close

guava/src/com/google/common/io/Closer.java:195–218  ·  view source on GitHub ↗

Closes all Closeable instances that have been added to this Closer. If an exception was thrown in the try block and passed to one of the exceptionThrown methods, any exceptions thrown when attempting to close a closeable will be suppressed. Otherwise, the first excepti

()

Source from the content-addressed store, hash-verified

193 * additional exceptions that are thrown after that will be suppressed.
194 */
195 @Override
196 public void close() throws IOException {
197 Throwable throwable = thrown;
198
199 // close closeables in LIFO order
200 while (!stack.isEmpty()) {
201 Closeable closeable = stack.removeFirst();
202 try {
203 closeable.close();
204 } catch (Throwable e) {
205 if (throwable == null) {
206 throwable = e;
207 } else {
208 suppressor.suppress(closeable, throwable, e);
209 }
210 }
211 }
212
213 if (thrown == null && throwable != null) {
214 throwIfInstanceOf(throwable, IOException.class);
215 throwIfUnchecked(throwable);
216 throw new AssertionError(throwable); // not possible
217 }
218 }
219
220 /** Suppression strategy interface. */
221 @VisibleForTesting

Callers 15

isEmptyMethod · 0.95
sizeMethod · 0.95
copyToMethod · 0.95
readMethod · 0.95
contentEqualsMethod · 0.95
sliceStreamMethod · 0.95
readMethod · 0.95
mapInternalMethod · 0.95
lengthMethod · 0.95
copyToMethod · 0.95
readMethod · 0.95
readFirstLineMethod · 0.95

Calls 5

isEmptyMethod · 0.65
suppressMethod · 0.65
removeFirstMethod · 0.45
throwIfInstanceOfMethod · 0.45
throwIfUncheckedMethod · 0.45