Add null checks to closeQuietly calls.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139738429
This commit is contained in:
dsantoro 2016-11-20 18:12:32 -08:00 committed by Oliver Woodman
parent 6dbfdecbe0
commit adc9dd1c75

View file

@ -210,7 +210,9 @@ public final class Util {
*/ */
public static void closeQuietly(DataSource dataSource) { public static void closeQuietly(DataSource dataSource) {
try { try {
dataSource.close(); if (dataSource != null) {
dataSource.close();
}
} catch (IOException e) { } catch (IOException e) {
// Ignore. // Ignore.
} }
@ -224,7 +226,9 @@ public final class Util {
*/ */
public static void closeQuietly(Closeable closeable) { public static void closeQuietly(Closeable closeable) {
try { try {
closeable.close(); if (closeable != null) {
closeable.close();
}
} catch (IOException e) { } catch (IOException e) {
// Ignore. // Ignore.
} }