Package com.spotify.fmt
Class ForkingExecutor
java.lang.Object
com.spotify.fmt.ForkingExecutor
- All Implemented Interfaces:
Closeable,AutoCloseable
An executor that executes a method in a sub-process JVM.
The function, its result and any thrown exception must be serializable as serialization is used to transport these between the processes.
Adapted from https://github.com/spotify/flo/blob/91d2e546bc8fa8e6fee9bc8c6dd484d87db3b0af/flo-runner/src/main/java/com/spotify/flo/context/ForkingExecutor.java
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ForkingExecutor.Execution<?>> private final org.apache.maven.plugin.logging.Logprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) ForkingExecutorclasspath(Collection<String> classpath) voidclose()private voidcopyLines(InputStream in, PrintStream out) private static void(package private) ForkingExecutorenvironment(Map<String, String> environment) (package private) <T> Texecute(SerializableCallable<T> f) Execute a function in a sub-process.(package private) ForkingExecutor(package private) ForkingExecutorprivate voidtryDeleteDir(Path path) (package private) ForkingExecutorwithDefaultClasspath(boolean withDefaultClasspath)
-
Field Details
-
log
private final org.apache.maven.plugin.logging.Log log -
executions
-
environment
-
javaArgs
-
withDefaultClasspath
private boolean withDefaultClasspath -
configuredClasspath
-
-
Constructor Details
-
ForkingExecutor
public ForkingExecutor(org.apache.maven.plugin.logging.Log log)
-
-
Method Details
-
environment
-
javaArgs
-
javaArgs
-
classpath
-
withDefaultClasspath
-
defaultClasspath
-
executionClassPath
-
execute
Execute a function in a sub-process.- Parameters:
f- The function to execute.- Returns:
- The return value of the function. Any exception thrown by the function the will be propagated and re-thrown.
- Throws:
IOException- if
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
tryDeleteDir
-
deleteDir
- Throws:
IOException
-
copyLines
-