Record Class SandboxResult

java.lang.Object
java.lang.Record
com.tnsai.quality.sandbox.SandboxResult
Record Components:
exitCode - process exit code; 0 = success by convention. -1 reserved for "killed by the sandbox before producing an exit code" (timeout, OOM, terminate while running).
stdout - stdout bytes (UTF-8 decoded by stdoutString())
stderr - stderr bytes
resourceUsage - post-execution accounting
timedOut - true if the sandbox killed the process because it exceeded ResourceLimits.timeout
outputTruncated - true if stdout+stderr hit ResourceLimits.maxOutputBytes and the process was killed

public record SandboxResult(int exitCode, byte[] stdout, byte[] stderr, ResourceUsage resourceUsage, boolean timedOut, boolean outputTruncated) extends Record
Outcome of a single Sandbox.execute(com.tnsai.quality.sandbox.Command) call (TNS-296).
Since:
0.10.0 (TNS-296)
  • Constructor Summary

    Constructors
    Constructor
    Description
    SandboxResult(int exitCode, byte[] stdout, byte[] stderr, ResourceUsage resourceUsage, boolean timedOut)
    Source-compatible 5-arg constructor — capture was not truncated.
    SandboxResult(int exitCode, byte[] stdout, byte[] stderr, ResourceUsage resourceUsage, boolean timedOut, boolean outputTruncated)
    Creates an instance of a SandboxResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the value of the exitCode record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the outputTruncated record component.
    Returns the value of the resourceUsage record component.
    byte[]
    Returns the value of the stderr record component.
    UTF-8 stderr view.
    byte[]
    Returns the value of the stdout record component.
    UTF-8 stdout view — the common-case accessor.
    boolean
    true if the process exited with a zero status and was not killed by the sandbox enforcement layer.
    boolean
    Returns the value of the timedOut record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SandboxResult

      public SandboxResult(int exitCode, byte[] stdout, byte[] stderr, ResourceUsage resourceUsage, boolean timedOut, boolean outputTruncated)
      Creates an instance of a SandboxResult record class.
      Parameters:
      exitCode - the value for the exitCode record component
      stdout - the value for the stdout record component
      stderr - the value for the stderr record component
      resourceUsage - the value for the resourceUsage record component
      timedOut - the value for the timedOut record component
      outputTruncated - the value for the outputTruncated record component
    • SandboxResult

      public SandboxResult(int exitCode, byte[] stdout, byte[] stderr, ResourceUsage resourceUsage, boolean timedOut)
      Source-compatible 5-arg constructor — capture was not truncated.
  • Method Details

    • stdoutString

      public String stdoutString()
      UTF-8 stdout view — the common-case accessor.
    • stderrString

      public String stderrString()
      UTF-8 stderr view.
    • success

      public boolean success()
      true if the process exited with a zero status and was not killed by the sandbox enforcement layer.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • exitCode

      public int exitCode()
      Returns the value of the exitCode record component.
      Returns:
      the value of the exitCode record component
    • stdout

      public byte[] stdout()
      Returns the value of the stdout record component.
      Returns:
      the value of the stdout record component
    • stderr

      public byte[] stderr()
      Returns the value of the stderr record component.
      Returns:
      the value of the stderr record component
    • resourceUsage

      public ResourceUsage resourceUsage()
      Returns the value of the resourceUsage record component.
      Returns:
      the value of the resourceUsage record component
    • timedOut

      public boolean timedOut()
      Returns the value of the timedOut record component.
      Returns:
      the value of the timedOut record component
    • outputTruncated

      public boolean outputTruncated()
      Returns the value of the outputTruncated record component.
      Returns:
      the value of the outputTruncated record component