Package org.zeroturnaround.exec.close
Class TimeoutProcessCloser
java.lang.Object
org.zeroturnaround.exec.close.StandardProcessCloser
org.zeroturnaround.exec.close.TimeoutProcessCloser
- All Implemented Interfaces:
ProcessCloser
Same as
StandardProcessCloser
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
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private final long
private final TimeUnit
Fields inherited from class org.zeroturnaround.exec.close.StandardProcessCloser
streams
-
Constructor Summary
ConstructorsConstructorDescriptionTimeoutProcessCloser
(ExecuteStreamHandler streams, long timeout, TimeUnit unit) Creates new instance ofTimeoutProcessCloser
. -
Method Summary
-
Field Details
-
log
private static final org.slf4j.Logger log -
timeout
private final long timeout -
unit
-
-
Constructor Details
-
TimeoutProcessCloser
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 Details
-
close
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:
IOException
- if I/O errors occur while closing the underlying streamInterruptedException
- if underlying throws a InterruptedException
-
doClose
- Throws:
IOException
InterruptedException
-
getUnitsAsString
-