Class CleanupThrowableUtil

java.lang.Object
org.exoplatform.addons.documents.cleanup.util.CleanupThrowableUtil

public class CleanupThrowableUtil extends Object
Renders a purge failure into the compact diagnostic persisted in the item's FAILURE_DETAIL column — never a full printStackTrace.

TWO links of the cause chain are kept, and two only: the HEAD exception (the one thrown) and the DEEPEST cause (the root cause). In ~99% of diagnoses those are the two that matter; every link in between repeats the same wrapping story and is redundant bulk. The intermediate links are never dropped SILENTLY though — their number is stated on its own line, so a reader knows exactly what they are not being shown.

Everything here is bounded on purpose. A deep JCR failure carrying an embedded SQL error runs to hundreds of KILOBYTES; at 800 GB of documents and hundreds of thousands of items per campaign, persisting that verbatim is a storage problem of its own. Hence MAX_FRAMES frames per block and, as the LAST step of the rendering — so no long single message can bypass it — a hard MAX_DETAIL_LENGTH character cap.

The chain WALK itself is delegated to commons-lang3 (ExceptionUtils), which carries a visited-set guard: a CYCLIC chain — A caused by B caused by A, which a re-wrapping layer can genuinely build — is cut, not spun on. A hand-rolled walk guarding only the self-cause spun forever on such a cycle, and it spun inside the purge worker, on a thread nothing interrupts. Only the frame rendering and the caps are ours.

  • Field Details

    • MAX_FRAMES

      public static final int MAX_FRAMES
      Stack frames kept per rendered block, the rest being counted, not shown.
      See Also:
    • MAX_DETAIL_LENGTH

      public static final int MAX_DETAIL_LENGTH
      Hard cap of the WHOLE rendered detail, enforced last.
      See Also:
  • Method Details

    • formatFailureDetail

      public static String formatFailureDetail(Throwable throwable)
      Compact diagnostic of a failure: the head exception block, the omitted intermediate-cause count when the chain had any, then the root-cause block — the whole thing capped at MAX_DETAIL_LENGTH characters.
      Parameters:
      throwable - failure to render, may be null
      Returns:
      the diagnostic to persist, or null when the throwable is null