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

improve TestKillRestart debugging

so we catch more output if stuff goes wrong
上级 79a16ace
......@@ -9,7 +9,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;
import org.h2.util.IOUtils;
/**
......@@ -51,29 +50,39 @@ public class OutputCatcher extends Thread {
@Override
public void run() {
StringBuilder buff = new StringBuilder();
while (true) {
try {
int x = in.read();
if (x < 0) {
break;
}
if (x < ' ') {
if (buff.length() > 0) {
String s = buff.toString();
buff.setLength(0);
synchronized (list) {
list.add(s);
list.notifyAll();
final StringBuilder buff = new StringBuilder();
try {
while (true) {
try {
int x = in.read();
if (x < 0) {
break;
}
if (x < ' ') {
if (buff.length() > 0) {
String s = buff.toString();
buff.setLength(0);
synchronized (list) {
list.add(s);
list.notifyAll();
}
}
} else {
buff.append((char) x);
}
} else {
buff.append((char) x);
} catch (IOException e) {
break;
}
}
IOUtils.closeSilently(in);
} finally {
// just in case something goes wrong, make sure we store any partial output we got
if (buff.length() > 0) {
synchronized (list) {
list.add(buff.toString());
list.notifyAll();
}
} catch (IOException e) {
break;
}
}
IOUtils.closeSilently(in);
}
}
......@@ -42,7 +42,7 @@ public class TestKillRestart extends TestBase {
int len = getSize(2, 15);
for (int i = 0; i < len; i++) {
Process p = Runtime.getRuntime().exec(procDef);
Process p = new ProcessBuilder().redirectErrorStream(true).command(procDef).start();
InputStream in = p.getInputStream();
OutputCatcher catcher = new OutputCatcher(in);
catcher.start();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论