/** * 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); }
/** * Gets first exception of given class from {@code 'cause'} hierarchy if any. * * @param cls Cause class to get cause (if {@code null}, {@code null} is returned). * @return First causing exception of passed in class, {@code null} otherwise. */ @Nullable public <T extends Throwable> T getCause(@Nullable Class<T> cls) { return X.cause(this, cls); }
/** * Alias for {@code System.err.println}. * * @param s1 First string to print. * @param rest Optional list of objects to print as well. */ public static void printerrln(@Nullable String s1, @Nullable Object... rest) { error(s1, rest); }
return null; Throwable cause = getCauseUsingWellKnownTypes(throwable); cause = getCauseUsingMethodName(throwable, mtdName); cause = getCauseUsingFieldName(throwable, "detail");
U.error(log, "Caught exception on handshake [err=" + e +", sock=" + sock + ']', e); if (X.hasCause(e, ObjectStreamException.class) || !sock.isClosed()) { if (U.isMacInvalidArgumentError(e)) LT.error(log, e, "Failed to initialize connection [sock=" + sock + "]\n\t" + "(make sure same versions of all classes are available on all nodes) " + "[rmtAddr=" + sock.getRemoteSocketAddress() + ", err=" + X.cause(e, ClassNotFoundException.class).getMessage() + ']'); "(make sure same versions of all classes are available on all nodes) " + "[rmtNodeId=" + nodeId + ", err=" + X.cause(e, ClassNotFoundException.class).getMessage() + ']'); (nodeAlive(nodeId) && spiStateCopy() == CONNECTED && !X.hasCause(e, IOException.class)); boolean err = X.hasCause(e, ObjectStreamException.class) || (nodeAlive(nodeId) && spiStateCopy() == CONNECTED);
return shallowClone(obj); Array.set(clone, i, deepClone(identityIdxs, clones, Array.get(obj, i), honorCloneable)); cloneField(identityIdxs, clones, obj, clone, f, honorCloneable);
/** {@inheritDoc} */ @Override public <T> T cloneValue(T val) throws GridException { return X.cloneObject(val, true, honorCloneable); } }
return !deep ? shallowClone(obj) : (T)deepClone(new GridLeanMap<Integer, Integer>(), new ArrayList<>(), obj, honorCloneable);
/** * Introspects the {@code Throwable} to obtain the cause. * * The method searches for methods with specific names that return a {@code Throwable} object. * This will pick up most wrapping exceptions, including those from JDK 1.4. * * The default list searched for are:</p> <ul> <li>{@code getCause()}</li> * <li>{@code getNextException()}</li> <li>{@code getTargetException()}</li> * <li>{@code getException()}</li> <li>{@code getSourceException()}</li> * <li>{@code getRootCause()}</li> <li>{@code getCausedByException()}</li> * <li>{@code getNested()}</li> </ul> * * <p>In the absence of any such method, the object is inspected for a {@code detail} * field assignable to a {@code Throwable}.</p> * * If none of the above is found, returns {@code null}. * * @param throwable The throwable to introspect for a cause, may be null. * @return The cause of the {@code Throwable}, * {@code null} if none found or null throwable input. */ public static Throwable getCause(Throwable throwable) { return getCause(throwable, CAUSE_MTD_NAMES); }
f.set(clone, f.get(obj)); else f.set(clone, deepClone(identityIdxs, clones, f.get(obj), honorCloneable));
/** {@inheritDoc} */ @Override public <T> T cloneValue(T val) throws GridException { return X.cloneObject(val, false, true); } }
/** * Returns the list of {@code Throwable} objects in the exception chain. * * A throwable without cause will return a list containing one element - the input throwable. * A throwable with one cause will return a list containing two elements - the input throwable * and the cause throwable. A {@code null} throwable will return a list of size zero. * * This method handles recursive cause structures that might otherwise cause infinite loops. * The cause chain is processed until the end is reached, or until the next item in the chain * is already in the result set.</p> * * @param throwable The throwable to inspect, may be null. * @return The list of throwables, never null. */ public static List<Throwable> getThrowableList(Throwable throwable) { List<Throwable> list = new ArrayList<>(); while (throwable != null && !list.contains(throwable)) { list.add(throwable); throwable = getCause(throwable); } return list; }
/** * 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); }
/** * */ public static void printMemoryStats() { X.println(">>>"); X.println(">>> GridOptimizedMarshallerUtils memory stats:"); X.println(" Cache size: " + CLS_DESC_CACHE.size()); for (Map.Entry<Class<?>, GridOptimizedClassDescriptor> e : CLS_DESC_CACHE.entrySet()) X.println(" " + e.getKey() + " : " + e.getValue()); }