提交 5f745a05 authored 作者: Noel Grandin's avatar Noel Grandin

close these connections quietly

we're not interesting in exceptions in closing in these tests
上级 7ca819d6
...@@ -34,9 +34,9 @@ public class IOUtils { ...@@ -34,9 +34,9 @@ public class IOUtils {
} }
/** /**
* Close an output stream without throwing an exception. * Close a Closeable without throwing an exception.
* *
* @param out the output stream or null * @param out the Closeablem or null
*/ */
public static void closeSilently(Closeable out) { public static void closeSilently(Closeable out) {
if (out != null) { if (out != null) {
...@@ -49,6 +49,22 @@ public class IOUtils { ...@@ -49,6 +49,22 @@ public class IOUtils {
} }
} }
/**
* Close an AutoCloseable without throwing an exception.
*
* @param out the AutoCloseable or null
*/
public static void closeSilently(AutoCloseable out) {
if (out != null) {
try {
trace("closeSilently", null, out);
out.close();
} catch (Exception e) {
// ignore
}
}
}
/** /**
* Skip a number of bytes in an input stream. * Skip a number of bytes in an input stream.
* *
......
...@@ -25,6 +25,7 @@ import org.h2.api.ErrorCode; ...@@ -25,6 +25,7 @@ import org.h2.api.ErrorCode;
import org.h2.jdbc.JdbcSQLException; import org.h2.jdbc.JdbcSQLException;
import org.h2.test.TestAll; import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.IOUtils;
import org.h2.util.SmallLRUCache; import org.h2.util.SmallLRUCache;
import org.h2.util.SynchronizedVerifier; import org.h2.util.SynchronizedVerifier;
import org.h2.util.Task; import org.h2.util.Task;
...@@ -374,7 +375,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -374,7 +375,7 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
} }
} finally { } finally {
conn.close(); IOUtils.closeSilently(conn);
executor.shutdown(); executor.shutdown();
executor.awaitTermination(20, TimeUnit.SECONDS); executor.awaitTermination(20, TimeUnit.SECONDS);
} }
...@@ -426,7 +427,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -426,7 +427,7 @@ public class TestMultiThread extends TestBase implements Runnable {
job.get(5, TimeUnit.MINUTES); job.get(5, TimeUnit.MINUTES);
} }
} finally { } finally {
conn.close(); IOUtils.closeSilently(conn);
executor.shutdown(); executor.shutdown();
executor.awaitTermination(20, TimeUnit.SECONDS); executor.awaitTermination(20, TimeUnit.SECONDS);
} }
...@@ -483,7 +484,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -483,7 +484,7 @@ public class TestMultiThread extends TestBase implements Runnable {
job.get(5, TimeUnit.MINUTES); job.get(5, TimeUnit.MINUTES);
} }
} finally { } finally {
conn.close(); IOUtils.closeSilently(conn);
executor.shutdown(); executor.shutdown();
executor.awaitTermination(20, TimeUnit.SECONDS); executor.awaitTermination(20, TimeUnit.SECONDS);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论