This commit is contained in:
Shinsuke Sugaya 2014-05-02 16:19:02 +09:00
parent 834d4df791
commit 16c28adc38
2 changed files with 35 additions and 14 deletions

View file

@ -19,6 +19,8 @@ package jp.sf.fess.helper;
import java.io.IOException;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import jp.sf.fess.FessSystemException;
import jp.sf.fess.job.JobExecutor;
@ -77,21 +79,38 @@ public class JobHelper {
logger.warn("Could not interrupt a thread of an input stream.",
e);
}
Process process = jobProcess.getProcess();
final CountDownLatch latch = new CountDownLatch(1);
final Process process = jobProcess.getProcess();
new Thread(new Runnable() {
@Override
public void run() {
try {
IOUtils.closeQuietly(process.getInputStream());
} catch (final Exception e) {
logger.warn("Could not close a process input stream.",
e);
}
try {
IOUtils.closeQuietly(process.getErrorStream());
} catch (final Exception e) {
logger.warn("Could not close a process error stream.",
e);
}
try {
IOUtils.closeQuietly(process.getOutputStream());
} catch (final Exception e) {
logger.warn("Could not close a process output stream.",
e);
}
latch.countDown();
}
}, "ProcessCloser").start();
try {
IOUtils.closeQuietly(process.getInputStream());
} catch (final Exception e) {
logger.warn("Could not close a process input stream.", e);
}
try {
IOUtils.closeQuietly(process.getErrorStream());
} catch (final Exception e) {
logger.warn("Could not close a process error stream.", e);
}
try {
IOUtils.closeQuietly(process.getOutputStream());
} catch (final Exception e) {
logger.warn("Could not close a process output stream.", e);
latch.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.warn("Interrupted to wait a process.", e);
}
try {
process.destroy();

View file

@ -39,6 +39,8 @@ public class InputStreamThread extends Thread {
private final List<String> list = new LinkedList<String>();
public InputStreamThread(final InputStream is, final String charset) {
super("InputStreamThread");
try {
br = new BufferedReader(new InputStreamReader(is, charset));
} catch (final UnsupportedEncodingException e) {