Package org.zeroturnaround.exec.close
Class TimeoutProcessCloser
- java.lang.Object
-
- org.zeroturnaround.exec.close.StandardProcessCloser
-
- org.zeroturnaround.exec.close.TimeoutProcessCloser
-
- All Implemented Interfaces:
ProcessCloser
public class TimeoutProcessCloser extends StandardProcessCloser
Same asStandardProcessCloserbut only waits fixed period for the closing. On timeout a warning is logged but no error is thrown.This is used on Windows where sometimes sub process' streams do not close properly.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Loggerlogprivate longtimeoutprivate java.util.concurrent.TimeUnitunit-
Fields inherited from class org.zeroturnaround.exec.close.StandardProcessCloser
streams
-
-
Constructor Summary
Constructors Constructor Description TimeoutProcessCloser(ExecuteStreamHandler streams, long timeout, java.util.concurrent.TimeUnit unit)Creates new instance ofTimeoutProcessCloser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(java.lang.Process process)Closes standard streams of a given sub process.protected voiddoClose(java.lang.Process process)private static java.lang.StringgetUnitsAsString(long d, java.util.concurrent.TimeUnit unit)
-
-
-
Constructor Detail
-
TimeoutProcessCloser
public TimeoutProcessCloser(ExecuteStreamHandler streams, long timeout, java.util.concurrent.TimeUnit unit)
Creates new instance ofTimeoutProcessCloser.- Parameters:
streams- helper for pumping the streams.timeout- how long should we wait for the closing.unit- unit of the timeout value.
-
-
Method Detail
-
close
public void close(java.lang.Process process) throws java.io.IOException, java.lang.InterruptedExceptionDescription copied from interface:ProcessCloserCloses standard streams of a given sub process.- Specified by:
closein interfaceProcessCloser- Overrides:
closein classStandardProcessCloser- Parameters:
process- sub process (notnull).- Throws:
java.io.IOException- if I/O errors occur while closing the underlying streamjava.lang.InterruptedException- if underlying throws a InterruptedException
-
doClose
protected void doClose(java.lang.Process process) throws java.io.IOException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
getUnitsAsString
private static java.lang.String getUnitsAsString(long d, java.util.concurrent.TimeUnit unit)
-
-