diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/io')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/io/SilentInputStream.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SilentInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SilentInputStream.java new file mode 100644 index 0000000000..8c2c61a434 --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SilentInputStream.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2025 Thomas Wolf <twolf@apache.org> and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +package org.eclipse.jgit.util.io; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An {@link InputStream} that swallows exceptions on {@link #close()}. + * + * @since 7.4 + */ +public class SilentInputStream extends FilterInputStream { + + private static final Logger LOG = LoggerFactory + .getLogger(SilentInputStream.class); + + /** + * Wraps an existing {@link InputStream}. + * + * @param in + * {@link InputStream} to wrap + */ + public SilentInputStream(InputStream in) { + super(in); + } + + @Override + public void close() throws IOException { + try { + super.close(); + } catch (IOException e) { + if (LOG.isDebugEnabled()) { + LOG.debug("Exception ignored while closing input stream", e); //$NON-NLS-1$ + } + } + } +} |