sk0x50 commented on code in PR #4923:
URL: https://github.com/apache/ignite-3/pull/4923#discussion_r1893820469


##########
modules/core/src/main/java/org/apache/ignite/internal/util/ExceptionUtils.java:
##########
@@ -332,6 +332,52 @@ public static String getFullStackTrace(Throwable 
throwable) {
         return sw.getBuffer().toString();
     }
 
+    /**
+     * Checks if passed in {@code 'Throwable'} has given class in {@code 
'cause'} hierarchy
+     * <b>including</b> that throwable itself.
+     * Note that this method follows includes {@link Throwable#getSuppressed()}
+     * into check.
+     *
+     * @param t Throwable to check (if {@code null}, {@code false} is 
returned).
+     * @param msg Message text that should be in cause.
+     * @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 String 
msg, Class<?> @Nullable... cls) {

Review Comment:
   Well, it is just a copy of the Apache Ignite 2 code. Of course, it does not 
mean that we cannot change it! I like the proposed `hasCauseOrSuppressed`.
   
   > Just a note: we have willThrowWithCauseOrSuppressed() in the codebase.
   
   It seems to me, that this particular test method cannot be applied in our 
case. So, I would stay with a new one (introduced in the patch).
   
   > Also, is it possible to rename parameters and variables to make them more 
human-readable?
   
   I will do it. Thanks for pointing this out.
   
   > And: this doesn't seem to tolerate cycles in the exception graph (except 
for a special case when cause equals the exception itself). I think we 
sometimes add suppressions in a way that creates such cycles. Should they be 
detected? I think I saw code for their detection somewhere (maybe it was in 
some test-only utility class).
   
   Do you mean something like as follows 
https://github.com/apache/ignite-3/blob/main/modules/api/src/main/java/org/apache/ignite/lang/util/TraceIdUtils.java#L42
 ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to