aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/io/SilentInputStream.java
blob: 8c2c61a434dd012f2e203cad4a3446c9a2aa9141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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$
			}
		}
	}
}