001/*************************************************** 002 * Licensed under MIT No Attribution (SPDX: MIT-0) * 003 ***************************************************/ 004 005package org.reactivestreams.tck.flow.support; 006 007 008/** 009 * Copy of scala.control.util.NonFatal in order to not depend on scala-library 010 */ 011public class NonFatal { 012 private NonFatal() { 013 // no instances, please. 014 } 015 016 /** 017 * Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal 018 * 019 * @param t throwable to be matched for fatal-ness 020 * @return true if is a non-fatal throwable, false otherwise 021 */ 022 public static boolean isNonFatal(Throwable t) { 023 if (t instanceof StackOverflowError) { 024 // StackOverflowError ok even though it is a VirtualMachineError 025 return true; 026 } else if (t instanceof VirtualMachineError || 027 t instanceof ThreadDeath || 028 t instanceof InterruptedException || 029 t instanceof LinkageError) { 030 // VirtualMachineError includes OutOfMemoryError and other fatal errors 031 return false; 032 } else { 033 return true; 034 } 035 } 036}