postgresql-jdbc.git / summary / log / commit / refs
commit 138d7ebcd338e6b2ff49d7b04748c8a89ac32bbb
Author: Sehrope Sarkuni <sehrope@jackdb.com>
Date: Sun Jan 24 16:54:46 2021 +0000
test: Add TestUtils.closeQuietly(...)
pgjdbc/src/test/java/org/postgresql/test/TestUtil.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/pgjdbc/src/test/java/org/postgresql/test/TestUtil.java b/pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
index e430c4c4..6c0e059b 100644
--- a/pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
+++ b/pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
@@ -17,6 +17,7 @@ import org.postgresql.util.PSQLException;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.Assert;
+import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -827,6 +828,18 @@ public class TestUtil {
return returnValue;
}
+ /**
+ * Close a resource and ignore any errors during closing.
+ */
+ public static void closeQuietly(@Nullable Closeable resource) {
+ if (resource != null) {
+ try {
+ resource.close();
+ } catch (Exception ignore) {
+ }
+ }
+ }
+
/**
* Close a Connection and ignore any errors during closing.
*/
[parent: d9bb70bf1859]