Package com.atlassian.confluence.util.sandbox
Sandbox framework enables running any java code independent of Confluence core in a separate OS process which can
crash, run out of memory, be killed and restarted without affecting Confluence.
Confluence provides the sandbox registry that can be imported and then used by a plugin to obtain a sandbox for running unsafe code. E.g.
SandboxSpec spec = SandboxSpec.builder()
.withMinimumMemoryInMb(512)
.build(Duration.ofSeconds(30));
Sandbox sandbox = sandboxRegistry.get(spec);
The obtained sandbox object then can be used for running different sandbox tasks.
SandboxTask<String, String> task = new ReverseStringTask();
sandbox.execute(task, "hello world");
Each instance of a sandbox is a java process with substantial amount of memory. There's a limited number of sandbox processes and they might be shared between Confluence core and plugins. For this reason, sandbox tasks should be created with as little time limit, as possible.
-
Interface Summary Interface Description Sandbox A sandbox is an object responsible for running java code in an isolated OS process.SandboxCallback<T,R> During the course of work aSandboxTask
which is executed in a sandbox process may need to ask the host for a specific information or an action.SandboxCallbackContext The execution context for aSandboxCallback
.SandboxErrorConsumer Consumer of a single line of sandbox standard error.SandboxRegistry This is the entry point for usage of sandbox API.SandboxSerializer<T> Handles Serialization/deserialization input and output forSandboxTask
.SandboxSpec Specification for the sandbox which will be used in searching the most suitable sandbox instance inSandboxRegistry
.SandboxSpec.SpecBuilder SandboxTask<T,R> Represents a task intended to be executed in a process sandbox.SandboxTaskContext The execution context for aSandboxTask
. -
Class Summary Class Description SandboxSerializers Utility methods for serialization/deserialization.SandboxSerializers.CompositeByteArraySerializer SandboxSerializers.DurationSerializer SandboxSerializers.IntSerializer SandboxSerializers.StringSerializer -
Exception Summary Exception Description SandboxCrashedException Is thrown when sandbox JVM has crashedSandboxException This error is thrown when sandbox failed to start or serve a request (e.g.SandboxNotFoundException This error is thrown when sandbox instance with given spec can't be obtainedSandboxStartupException If thrown when the sandbox process has been failed to startSandboxTimeoutException Is thrown when the sandbox process has been killed due to the timeout