/** * Checks if this exception has given class in {@code 'cause'} hierarchy. * * @param cls Cause classes to check (if {@code null} or empty, {@code false} is returned). * @return {@code True} if one of the causing exception is an instance of passed in classes, * {@code false} otherwise. */ public boolean hasCause(@Nullable Class<? extends Throwable>... cls) { return X.hasCause(this, cls); }
/** * Checks if this exception has given class in {@code 'cause'} hierarchy. * * @param cls Cause class to check (if {@code null}, {@code false} is returned).. * @return {@code True} if one of the causing exception is an instance of passed in class, * {@code false} otherwise. */ public boolean hasCause(@Nullable Class<? extends Throwable>... cls) { return X.hasCause(this, cls); }
/** * Checks if this exception has given class in {@code 'cause'} hierarchy. * * @param cls Cause class to check (if {@code null}, {@code false} is returned).. * @return {@code True} if one of the causing exception is an instance of passed in class, * {@code false} otherwise. */ public boolean hasCause(@Nullable Class<? extends Throwable>... cls) { return X.hasCause(this, cls); }
/** * Gets error code based on exception class. * * @param e Exception to analyze. * @param checkIo Whether to check for IO exception. * @return Error code. */ @SuppressWarnings("unchecked") private int errorCode(GridException e, boolean checkIo) { if (X.hasCause(e, GridGgfsFileNotFoundException.class)) return ERR_FILE_NOT_FOUND; else if (GridGgfsPathAlreadyExistsException.class.isInstance(e)) return ERR_PATH_ALREADY_EXISTS; else if (GridGgfsDirectoryNotEmptyException.class.isInstance(e)) return ERR_DIRECTORY_NOT_EMPTY; else if (GridGgfsParentNotDirectoryException.class.isInstance(e)) return ERR_PARENT_NOT_DIRECTORY; else if (GridGgfsInvalidHdfsVersionException.class.isInstance(e)) return ERR_INVALID_HDFS_VERSION; else if (X.hasCause(e, GridGgfsCorruptedFileException.class)) return ERR_CORRUPTED_FILE; // This check should be the last. else if (GridGgfsException.class.isInstance(e)) return ERR_GGFS_GENERIC; return ERR_GENERIC; }
/** * Gets error code based on exception class. * * @param e Exception to analyze. * @param checkIo Whether to check for IO exception. * @return Error code. */ @SuppressWarnings("unchecked") private int errorCode(GridException e, boolean checkIo) { if (X.hasCause(e, GridGgfsFileNotFoundException.class)) return ERR_FILE_NOT_FOUND; else if (GridGgfsPathAlreadyExistsException.class.isInstance(e)) return ERR_PATH_ALREADY_EXISTS; else if (GridGgfsDirectoryNotEmptyException.class.isInstance(e)) return ERR_DIRECTORY_NOT_EMPTY; else if (GridGgfsParentNotDirectoryException.class.isInstance(e)) return ERR_PARENT_NOT_DIRECTORY; else if (GridGgfsInvalidHdfsVersionException.class.isInstance(e)) return ERR_INVALID_HDFS_VERSION; else if (X.hasCause(e, GridGgfsCorruptedFileException.class)) return ERR_CORRUPTED_FILE; // This check should be the last. else if (GridGgfsException.class.isInstance(e)) return ERR_GGFS_GENERIC; return ERR_GENERIC; }
/** * Checks if passed in {@code 'Throwable'} has given class in {@code 'cause'} hierarchy * <b>excluding</b> that throwable itself. * <p> * Note that this method follows includes {@link Throwable#getSuppressed()} * into check. * * @param t Throwable to check (if {@code null}, {@code false} is returned). * @param cls Cause classes to check (if {@code null} or empty, {@code false} is returned). * @return {@code True} if one of the causing exception is an instance of passed in classes, * {@code false} otherwise. */ public static boolean hasCauseExcludeRoot(@Nullable Throwable t, @Nullable Class<? extends Throwable>... cls) { if (t == null || F.isEmpty(cls)) return false; assert cls != null; for (Throwable th = t.getCause(); th != null; th = th.getCause()) { for (Class<? extends Throwable> c : cls) { if (c.isAssignableFrom(th.getClass())) return true; } if (th.getCause() == th) break; } for (Throwable n : t.getSuppressed()) { if (hasCause(n, cls)) return true; } return false; }
/** * Checks if passed in {@code 'Throwable'} has given class in {@code 'cause'} hierarchy * <b>including</b> that throwable itself. * <p> * Note that this method follows includes {@link Throwable#getSuppressed()} * into check. * * @param t Throwable to check (if {@code null}, {@code false} is returned). * @param cls Cause classes to check (if {@code null} or empty, {@code false} is returned). * @return {@code True} if one of the causing exception is an instance of passed in classes, * {@code false} otherwise. */ public static boolean hasCause(@Nullable Throwable t, @Nullable Class<? extends Throwable>... cls) { if (t == null || F.isEmpty(cls)) return false; assert cls != null; for (Throwable th = t; th != null; th = th.getCause()) { for (Class<? extends Throwable> c : cls) { if (c.isAssignableFrom(th.getClass())) return true; } for (Throwable n : th.getSuppressed()) { if (hasCause(n, cls)) return true; } if (th.getCause() == th) break; } return false; }
if (X.hasCause(e, SocketTimeoutException.class)) LT.warn(log, null, "Timed out waiting for message to be read (most probably, the reason is " + "in long GC pauses on remote node. Current timeout: " + timeout + '.');
/** {@inheritDoc} */ @Override public GridBiTuple<Collection<GridConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( URL cfgUrl, String... excludedProps) throws GridException { ApplicationContext springCtx; try { springCtx = applicationContext(cfgUrl, excludedProps); } catch (BeansException e) { if (X.hasCause(e, ClassNotFoundException.class)) throw new GridException("Failed to instantiate Spring XML application context " + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + "[springUrl=" + cfgUrl + ']', e); else throw new GridException("Failed to instantiate Spring XML application context [springUrl=" + cfgUrl + ", err=" + e.getMessage() + ']', e); } Map<String, GridConfiguration> cfgMap; try { cfgMap = springCtx.getBeansOfType(GridConfiguration.class); } catch (BeansException e) { throw new GridException("Failed to instantiate bean [type=" + GridConfiguration.class + ", err=" + e.getMessage() + ']', e); } if (cfgMap == null || cfgMap.isEmpty()) throw new GridException("Failed to find grid configuration in: " + cfgUrl); return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx)); }
if (X.hasCause(e, ClassNotFoundException.class)) note = "\nNote! You may use 'USER_LIBS' environment variable to specify your classpath.";
if (X.hasCause(e, GridInternalException.class) || X.hasCause(e, GridGgfsOutOfSpaceException.class)) { "GridComputeTask.result(..) method (will fail the whole task): " + jobRes, e); else if (X.hasCause(e, GridComputeJobFailoverException.class)) { GridException e0 = new GridException(" Job was not failed over because " + "GridComputeJobResultPolicy.FAILOVER was not returned from " + if (X.hasCause(e, GridInternalException.class) || X.hasCause(e, GridGgfsOutOfSpaceException.class)) { "GridComputeTask.result(..) method (will fail the whole task): " + jobRes, e); else if (X.hasCause(e, GridComputeJobFailoverException.class)) { GridException e0 = new GridException(" Job was not failed over because " + "GridComputeJobResultPolicy.FAILOVER was not returned from " +
/** {@inheritDoc} */ @Override public Map<Class<?>, Object> loadBeans(URL cfgUrl, Class<?>... beanClasses) throws GridException { assert beanClasses.length > 0; GenericApplicationContext springCtx; try { springCtx = new GenericApplicationContext(); new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); springCtx.refresh(); } catch (BeansException e) { if (X.hasCause(e, ClassNotFoundException.class)) throw new GridException("Failed to instantiate Spring XML application context " + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + "[springUrl=" + cfgUrl + ']', e); else throw new GridException("Failed to instantiate Spring XML application context [springUrl=" + cfgUrl + ", err=" + e.getMessage() + ']', e); } Map<Class<?>, Object> beans = new HashMap<>(); for (Class<?> cls : beanClasses) beans.put(cls, bean(springCtx, cls)); return beans; }
if (!nearNode.id().equals(ctx.nodeId()) && !X.hasCause(err, GridDistributedLockCancelledException.class)) ctx.io().send(nearNode, res);
if (cacheMsg.ignoreClassErrors() && X.hasCause(e, InvalidClassException.class, ClassNotFoundException.class, NoClassDefFoundError.class, UnsupportedClassVersionError.class)) cacheMsg.onClassError(e); if (cacheMsg.ignoreClassErrors() && X.hasCause(e, NoClassDefFoundError.class, UnsupportedClassVersionError.class)) cacheMsg.onClassError(new GridException("Failed to load class during unmarshalling: " + e, e));
if (connectAttempts < 2 && X.hasCause(e, ConnectException.class)) { connectAttempts++;
else if (sysStopping && X.hasCause(e, InterruptedException.class, GridInterruptedException.class)) { msg = "Job got interrupted due to system stop (will attempt failover).";
if (CU.isUtilityCache(cctx.name()) && X.hasCause(e, ClassNotFoundException.class)) U.error(log, "Failed to process message (note that distributed services " + "do not support peer class loading, if you deploy distributed service " +