Class ExceptionHandling

java.lang.Object
org.mockserver.exception.ExceptionHandling

public class ExceptionHandling extends Object
  • Constructor Details

    • ExceptionHandling

      public ExceptionHandling()
  • Method Details

    • handleThrowable

      public static <T> T handleThrowable(CompletableFuture<T> future, long timeout, TimeUnit unit)
    • handleThrowable

      public static <T> T handleThrowable(Callable<T> callable)
    • swallowThrowable

      public static void swallowThrowable(ExceptionHandling.ThrowingRunnable runnable)
    • sniDescription

      public static String sniDescription(io.netty.channel.Channel... channels)
      Returns a log suffix identifying the SNI hostname of the failed connection, formatted as " (SNI: <host>)", using the first non-null SNI hostname found across the given channels, or "" when none of the channels carried an SNI hostname. Several channels can be passed (e.g. relay handlers hold both an upstream and a downstream channel) so the SNI is found whichever channel recorded it. Null-safe — a null array, or null elements within it, are skipped.
      Parameters:
      channels - the channels to search for a recorded SNI hostname
      Returns:
      " (SNI: <host>)" for the first hostname found, otherwise ""
    • closeOnFlush

      public static void closeOnFlush(io.netty.channel.Channel ch)
      Closes the specified channel after all queued write requests are flushed.
    • connectionClosedException

      public static boolean connectionClosedException(Throwable throwable)
      returns true is the exception was caused by the connection being closed
    • isSslOrDecoderFault

      public static boolean isSslOrDecoderFault(Throwable throwable)
      returns true if the exception is a genuine SSL or decoder fault, i.e. the SSL/decoder subset that connectionClosedException(Throwable) returns false for at lines 123-124 (an SSLException cause, a DecoderException, or a NotSslRecordException). Note that connectionClosedException also returns false for benign connection resets via its message-regex and stack-trace inspection; those are NOT matched here. Callers can use this to surface real SSL/decoder faults at WARN rather than dropping them silently alongside benign connection closes.
    • sslHandshakeException

      public static boolean sslHandshakeException(Throwable throwable)
    • connectionException

      public static boolean connectionException(Throwable throwable)