001/************************************************************************ 002 * Licensed under Public Domain (CC0) * 003 * * 004 * To the extent possible under law, the person who associated CC0 with * 005 * this code has waived all copyright and related or neighboring * 006 * rights to this code. * 007 * * 008 * You should have received a copy of the CC0 legalcode along with this * 009 * work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.* 010 ************************************************************************/ 011 012package org.reactivestreams.tck.flow.support; 013 014 015/** 016 * Copy of scala.control.util.NonFatal in order to not depend on scala-library 017 */ 018public class NonFatal { 019 private NonFatal() { 020 // no instances, please. 021 } 022 023 /** 024 * Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal 025 * 026 * @param t throwable to be matched for fatal-ness 027 * @return true if is a non-fatal throwable, false otherwise 028 */ 029 public static boolean isNonFatal(Throwable t) { 030 if (t instanceof StackOverflowError) { 031 // StackOverflowError ok even though it is a VirtualMachineError 032 return true; 033 } else if (t instanceof VirtualMachineError || 034 t instanceof ThreadDeath || 035 t instanceof InterruptedException || 036 t instanceof LinkageError) { 037 // VirtualMachineError includes OutOfMemoryError and other fatal errors 038 return false; 039 } else { 040 return true; 041 } 042 } 043}