001package org.reactivestreams.tck.support;
002
003
004/**
005 * Copy of scala.control.util.NonFatal in order to not depend on scala-library
006 */
007public class NonFatal {
008  /**
009   * Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal
010   */
011  public static boolean apply(Throwable t) {
012    if (t instanceof StackOverflowError) {
013      // StackOverflowError ok even though it is a VirtualMachineError
014      return true;
015    } else if (t instanceof VirtualMachineError ||
016        t instanceof ThreadDeath ||
017        t instanceof InterruptedException ||
018        t instanceof LinkageError) {
019      // VirtualMachineError includes OutOfMemoryError and other fatal errors
020      return false;
021    } else {
022      return true;
023    }
024  }
025}