Commit adc9dd1c by dsantoro Committed by Oliver Woodman

Add null checks to closeQuietly calls.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139738429
parent 6dbfdecb
...@@ -210,7 +210,9 @@ public final class Util { ...@@ -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 { ...@@ -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.
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment