br.com.objectos.lang.CloserJava6 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectos-lang Show documentation
Show all versions of objectos-lang Show documentation
A set of utilities for classes of the java.lang and the java.util packages.
The newest version!
/*
* Copyright (C) 2011-2021 Objectos Software LTDA.
*
* This file is part of the ObjectosComuns project.
*
* ObjectosComuns is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ObjectosComuns is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ObjectosComuns. If not, see .
*/
package br.com.objectos.lang;
import br.com.objectos.logging.Event1;
import br.com.objectos.logging.Logger;
import br.com.objectos.logging.Logging;
import br.com.objectos.multirelease.Singleton;
import java.io.Closeable;
import java.io.IOException;
import java.util.zip.ZipFile;
final class CloserJava6 extends Closer {
@Singleton.Field
static final Closer INSTANCE = new CloserJava6();
private static final Event1 SUPPRESSED;
static {
Class> s;
s = Closer.class;
SUPPRESSED = Logging.warn(s, "SUPPRESSED", Exception.class);
}
private final Logger logger = Logging.getNoopLogger();
private CloserJava6() {}
@Override
public final IOException close(IOException rethrow, Closeable closeable) {
IOException result;
result = rethrow;
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
if (result != null) {
logger.log(SUPPRESSED, e);
} else {
result = e;
}
}
}
return result;
}
@Override
public final IOException close(IOException rethrow, ZipFile file) {
IOException result;
result = rethrow;
if (file != null) {
try {
file.close();
} catch (IOException e) {
if (result != null) {
logger.log(SUPPRESSED, e);
} else {
result = e;
}
}
}
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy