use debug log in IOUtils.closeQuietly

This commit is contained in:
Hannes Janetzek 2014-04-03 05:53:19 +02:00
parent cb5de5135f
commit e84afa32f7

View File

@ -19,39 +19,44 @@ package org.oscim.utils;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.util.logging.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* A utility class with IO-specific helper methods. * A utility class with IO-specific helper methods.
*/ */
public final class IOUtils { public final class IOUtils {
final static Logger log = LoggerFactory.getLogger(IOUtils.class);
/** /**
* Invokes the {@link Closeable#close()} method on the given object. If an * Invokes the {@link Closeable#close()} method on the given object. If an
* {@link IOException} occurs during the * {@link IOException} occurs during the
* method call, it will be caught and logged on level {@link Level#WARNING}. * method call, it will be caught and logged.
* *
* @param closeable * @param closeable
* the data source which should be closed (may be null). * the data source which should be closed (may be null).
*/ */
public static void closeQuietly(Closeable closeable) { public static void closeQuietly(Closeable closeable) {
if (closeable == null)
return;
try { try {
if (closeable != null) {
closeable.close(); closeable.close();
}
} catch (IOException e) { } catch (IOException e) {
//log.debug(e.getMessage() + " " + e); log.debug(e.getMessage());
} }
} }
/* for old java versions */ /* for old java versions */
public static void closeQuietly(Socket closeable) { public static void closeQuietly(Socket closeable) {
if (closeable == null)
return;
try { try {
if (closeable != null) {
closeable.close(); closeable.close();
}
} catch (IOException e) { } catch (IOException e) {
//log.debug(e.getMessage() + " " + e); log.debug(e.getMessage());
} }
} }