Package com.atlassian.confluence.util.sandbox
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.
-
ClassDescriptionA 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.The execution context for aSandboxCallback
.Is thrown when sandbox JVM has crashedConsumer of a single line of sandbox standard error.This error is thrown when sandbox failed to start or serve a request (e.g.This error is thrown when sandbox instance with given spec can't be obtainedThis is the entry point for usage of sandbox API.Handles Serialization/deserialization input and output forSandboxTask
.Utility methods for serialization/deserialization.Specification for the sandbox which will be used in searching the most suitable sandbox instance inSandboxRegistry
.If thrown when the sandbox process has been failed to startSandboxTask<T,R> Represents a task intended to be executed in a process sandbox.The execution context for aSandboxTask
.Is thrown when the sandbox process has been killed due to the timeout