Make PipelineUtil.containsCause check if the instance is of the class type

This commit is contained in:
creeper123123321 2019-05-01 11:31:36 -03:00
parent 7f6069e76b
commit 6b58d86248
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1

View File

@ -6,7 +6,6 @@ import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.MessageToMessageEncoder;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -90,14 +89,15 @@ public class PipelineUtil {
* *
* @param t The throwable * @param t The throwable
* @param c The exception to look for * @param c The exception to look for
* @return True if the stack trace contained it as its cause. * @return True if the stack trace contained it as its cause or if t is an instance of c.
*/ */
public static boolean containsCause(Throwable t, Class<? extends Throwable> c) { public static boolean containsCause(Throwable t, Class<? extends Throwable> c) {
while (t != null) { do {
t = t.getCause(); if (t != null) {
if (t != null)
if (c.isAssignableFrom(t.getClass())) return true; if (c.isAssignableFrom(t.getClass())) return true;
t = t.getCause();
} }
} while (t != null);
return false; return false;
} }