Class UdfConsoleCapture

java.lang.Object
dev.frostlake.executor.udf.UdfConsoleCapture

public final class UdfConsoleCapture extends Object
Routes a JVM-handler UDF's console output (System.out/System.err written on the invoking thread) into the engine log instead of the embedder's console. Snowflake never surfaces a UDF's console output to the SQL client — e.g. an ANTLR-based handler's default error listener printing line 1:1 missing '\n' at … on every recovered parse — so an embedder's test run should not see it either; it lands here as dev.frostlake.udf.console INFO lines.

Installation swaps System.out/System.err for pass-through wrappers (UdfConsoleStream) the first time a handler runs; threads outside enter()/ exit() write through to the original streams byte-for-byte. A test harness may replace the system streams between tests (Surefire does), so enter() re-installs when the wrapper has been displaced. The relay guard stops recursion when the log appender itself writes to the console.

  • Method Details

    • enter

      public static void enter()
      Mark the current thread as executing a UDF handler; console writes are captured until exit().
    • exit

      public static void exit()
      Leave the handler scope entered by enter() (call from a finally block).