Class WaitForProcess

  • All Implemented Interfaces:
    java.util.concurrent.Callable<ProcessResult>

    class WaitForProcess
    extends java.lang.Object
    implements java.util.concurrent.Callable<ProcessResult>
    Handles the executed process.
    • Field Detail

      • log

        private static final org.slf4j.Logger log
      • process

        private final java.lang.Process process
      • attributes

        private final ProcessAttributes attributes
        Set of main attributes used to start the process.
      • stopper

        private final ProcessStopper stopper
        Helper for stopping the process in case of interruption.
      • closer

        private final ProcessCloser closer
        Helper for closing the process' standard streams.
      • out

        private final java.io.ByteArrayOutputStream out
        Buffer where the process output is redirected to or null if it's not used.
      • listener

        private final ProcessListener listener
        Process event listener (not null).
      • messageLogger

        private final MessageLogger messageLogger
        Helper for logging messages about starting and waiting for the processes.
      • workerThread

        private volatile java.lang.Thread workerThread
        Thread which executes this operation.
    • Method Detail

      • getProcess

        public java.lang.Process getProcess()
        Returns:
        the sub process.
      • call

        public ProcessResult call()
                           throws java.io.IOException,
                                  java.lang.InterruptedException
        Specified by:
        call in interface java.util.concurrent.Callable<ProcessResult>
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • addExceptionMessageSuffix

        public void addExceptionMessageSuffix​(java.lang.StringBuilder sb)
        Adds a suffix for an error message including:
        • executed command
        • working directory (unless it's inherited from parent)
        • environment (unless it's the same with the parent)
        • output read so far (unless it's not read)
        Parameters:
        sb - where the suffix is appended to.
      • getStackTrace

        public java.lang.StackTraceElement[] getStackTrace()
        Returns:
        current stacktrace of the worker thread, null if this operation is currently not running.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object