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 asStandardProcessCloser
but 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.Logger
log
private long
timeout
private java.util.concurrent.TimeUnit
unit
-
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 void
close(java.lang.Process process)
Closes standard streams of a given sub process.protected void
doClose(java.lang.Process process)
private static java.lang.String
getUnitsAsString(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.InterruptedException
Description copied from interface:ProcessCloser
Closes standard streams of a given sub process.- Specified by:
close
in interfaceProcessCloser
- Overrides:
close
in 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.IOException
java.lang.InterruptedException
-
getUnitsAsString
private static java.lang.String getUnitsAsString(long d, java.util.concurrent.TimeUnit unit)
-
-