提交 c23bb0ed authored 作者: Noel Grandin's avatar Noel Grandin

close a couple of resource leaks

上级 c1087334
......@@ -11,7 +11,6 @@ import java.io.LineNumberReader;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.h2.test.TestBase;
import org.h2.util.ScriptReader;
......@@ -43,7 +42,7 @@ public class TestScriptSimple extends TestBase {
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
LineNumberReader lineReader = new LineNumberReader(
new InputStreamReader(is, "Cp1252"));
ScriptReader reader = new ScriptReader(lineReader);
try (ScriptReader reader = new ScriptReader(lineReader)) {
while (true) {
String sql = reader.readStatement();
if (sql == null) {
......@@ -70,7 +69,7 @@ public class TestScriptSimple extends TestBase {
throw e;
}
}
is.close();
}
conn.close();
deleteDb("scriptSimple");
}
......
......@@ -46,7 +46,7 @@ public class TestScriptReader extends TestBase {
}
String s = buff.toString();
StringReader reader = new StringReader(s);
ScriptReader source = new ScriptReader(reader);
try (ScriptReader source = new ScriptReader(reader)) {
for (int j = 0; j < l; j++) {
String e = source.readStatement();
String c = sql[j];
......@@ -58,6 +58,7 @@ public class TestScriptReader extends TestBase {
assertEquals(null, source.readStatement());
}
}
}
private static String randomStatement(Random random) {
StringBuilder buff = new StringBuilder();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论