/** * Returns true if the exception is triggered by query cancel. * * @param e Exception. * @return {@code true} if exception is caused by cancel. */ private boolean wasCancelled(CacheException e) { return X.hasSuppressed(e, QueryCancelledException.class); }
/** * Checks if passed throwable has given class in one of the suppressed exceptions. * * @param t Throwable to check (if {@code null}, {@code false} is returned). * @param cls Class to check. * @return {@code True} if one of the suppressed exceptions is an instance of passed class, * {@code false} otherwise. */ public static boolean hasSuppressed(@Nullable Throwable t, @Nullable Class<? extends Throwable> cls) { if (t == null || cls == null) return false; for (Throwable th : t.getSuppressed()) { if (cls.isAssignableFrom(th.getClass())) return true; if (hasSuppressed(th, cls)) return true; } return false; }
if (X.hasCause(e, CacheStoppedException.class) || X.hasSuppressed(e, CacheStoppedException.class)) throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " + cacheName, e);
/** * Returns true if the exception is triggered by query cancel. * * @param e Exception. * @return {@code true} if exception is caused by cancel. */ private boolean wasCancelled(CacheException e) { return X.hasSuppressed(e, QueryCancelledException.class); }
/** * Checks if passed throwable has given class in one of the suppressed exceptions. * * @param t Throwable to check (if {@code null}, {@code false} is returned). * @param cls Class to check. * @return {@code True} if one of the suppressed exceptions is an instance of passed class, * {@code false} otherwise. */ public static boolean hasSuppressed(@Nullable Throwable t, @Nullable Class<? extends Throwable> cls) { if (t == null || cls == null) return false; for (Throwable th : t.getSuppressed()) { if (cls.isAssignableFrom(th.getClass())) return true; if (hasSuppressed(th, cls)) return true; } return false; }
/** * Method converts exception to IgniteCacheRestartingException in case of cache restarting * or to CacheException in other cases. * * @param e {@code IgniteCheckedException} or {@code IgniteException}. * @return Cache exception. */ private RuntimeException cacheException(Exception e) { GridFutureAdapter<Void> restartFut = this.restartFut.get(); if (restartFut != null) { if (X.hasCause(e, CacheStoppedException.class) || X.hasSuppressed(e, CacheStoppedException.class)) throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " + ctx.name(), e); } if (e instanceof IgniteException && X.hasCause(e, CacheException.class)) e = X.cause(e, CacheException.class); if (e instanceof IgniteCheckedException) return CU.convertToCacheException((IgniteCheckedException) e); if (X.hasCause(e, CacheStoppedException.class)) return CU.convertToCacheException(X.cause(e, CacheStoppedException.class)); if (e instanceof RuntimeException) return (RuntimeException) e; throw new IllegalStateException("Unknown exception", e); }