class FailureUtils {

  public static boolean isDirectMemoryOOM(Throwable e) {
    if (e instanceof OutOfDirectMemoryError || e instanceof OutOfMemoryException) {
      // These are always direct memory errors
      return true;
    }

    return (e instanceof OutOfMemoryError) && DIRECT_MEMORY_OOM_MESSAGE.equals(e.getMessage());
  }

  private  FailureUtils();

}