improve utils

This commit is contained in:
Sebastian Sdorra
2010-09-28 20:19:18 +02:00
parent af7b7b8e4d
commit 6fec6196a0
19 changed files with 483 additions and 126 deletions

View File

@@ -9,7 +9,7 @@ package sonia.scm.web.cgi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.Util;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -164,6 +164,11 @@ public class CGIRunner
execCmd = cmdPrefix + " " + execCmd;
}
if (logger.isLoggable(Level.FINE))
{
logger.fine("execute cgi: ".concat(execCmd));
}
Process p = (dir == null)
? Runtime.getRuntime().exec(execCmd, env.getEnvArray())
: Runtime.getRuntime().exec(execCmd, env.getEnvArray(), dir);
@@ -193,6 +198,11 @@ public class CGIRunner
{
logger.log(Level.FINEST, null, e);
}
finally
{
IOUtil.close(inFromReq);
IOUtil.close(outToCgi);
}
}
}).start();
@@ -244,7 +254,7 @@ public class CGIRunner
// copy cgi content to response stream...
os = res.getOutputStream();
Util.copy(inFromCgi, os);
IOUtil.copy(inFromCgi, os);
p.waitFor();
if (!ignoreExitState)
@@ -280,7 +290,7 @@ public class CGIRunner
{
if (os != null)
{
Util.close(os);
IOUtil.close(os);
}
os = null;