All Downloads are FREE. Search and download functionalities are using the official Maven repository.

biz.paluch.logging.gelf.intern.Closer Maven / Gradle / Ivy

The newest version!
package biz.paluch.logging.gelf.intern;

import java.io.Closeable;
import java.io.IOException;
import java.net.Socket;

/**
 * Internal helper to silently close resources.
 *
 * @author Mark Paluch
 * @since 17.07.14 10:45
 */
public class Closer {

    private Closer() {
        // no instance allowed
    }

    /**
     * Close silently the closeable.
     *
     * @param closeable the closeable
     */
    public static final void close(Closeable closeable) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (IOException e) {
            // ignore
        }
    }

    /**
     * Close silently the socket.
     *
     * @param socket the socket
     */
    public static final void close(Socket socket) {
        try {
            if (socket != null) {
                socket.close();
            }
        } catch (IOException e) {
            // ignore
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy