Home / Class/ ThrowableUtil Class — netty Architecture

ThrowableUtil Class — netty Architecture

Architecture documentation for the ThrowableUtil class in ThrowableUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  069a887c_f684_b6c1_9696_6231a3e9cdcc["ThrowableUtil"]
  b46b6f2b_2471_6d89_1c61_9b336047fa35["ThrowableUtil.java"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|defined in| b46b6f2b_2471_6d89_1c61_9b336047fa35
  94c31596_6468_126a_d197_3fdb4ee74ce0["ThrowableUtil()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| 94c31596_6468_126a_d197_3fdb4ee74ce0
  305accca_3e75_5650_7d09_7d948b7dae55["T()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| 305accca_3e75_5650_7d09_7d948b7dae55
  b417add4_158e_2221_4a96_264fe130554e["String()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| b417add4_158e_2221_4a96_264fe130554e
  c342f370_9afd_8cf4_05bd_3d6532759839["haveSuppressed()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| c342f370_9afd_8cf4_05bd_3d6532759839
  583550d9_f7dc_1d80_95b3_67c9998f6800["addSuppressed()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| 583550d9_f7dc_1d80_95b3_67c9998f6800
  1fab92d1_b790_4189_6694_68c3307505e6["addSuppressedAndClear()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| 1fab92d1_b790_4189_6694_68c3307505e6
  9119ff75_9474_d9dd_93f4_e59a5e3b3e40["getSuppressed()"]
  069a887c_f684_b6c1_9696_6231a3e9cdcc -->|method| 9119ff75_9474_d9dd_93f4_e59a5e3b3e40

Relationship Graph

Source Code

common/src/main/java/io/netty/util/internal/ThrowableUtil.java lines 23–83

public final class ThrowableUtil {

    private ThrowableUtil() { }

    /**
     * Set the {@link StackTraceElement} for the given {@link Throwable}, using the {@link Class} and method name.
     */
    public static <T extends Throwable> T unknownStackTrace(T cause, Class<?> clazz, String method) {
        cause.setStackTrace(new StackTraceElement[] { new StackTraceElement(clazz.getName(), method, null, -1)});
        return cause;
    }

    /**
     * Gets the stack trace from a Throwable as a String.
     *
     * @param cause the {@link Throwable} to be examined
     * @return the stack trace as generated by {@link Throwable#printStackTrace(java.io.PrintWriter)} method.
     */
    @Deprecated
    public static String stackTraceToString(Throwable cause) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream pout = new PrintStream(out);
        cause.printStackTrace(pout);
        pout.flush();
        try {
            return out.toString();
        } finally {
            try {
                out.close();
            } catch (IOException ignore) {
                // ignore as should never happen
            }
        }
    }

    @Deprecated
    public static boolean haveSuppressed() {
        return true;
    }

    public static void addSuppressed(Throwable target, Throwable suppressed) {
        if (suppressed != null) {
            target.addSuppressed(suppressed);
        }
    }

    public static void addSuppressedAndClear(Throwable target, List<Throwable> suppressed) {
        addSuppressed(target, suppressed);
        suppressed.clear();
    }

    public static void addSuppressed(Throwable target, List<Throwable> suppressed) {
        for (Throwable t : suppressed) {
            addSuppressed(target, t);
        }
    }

    public static Throwable[] getSuppressed(Throwable source) {
        return source.getSuppressed();
    }
}

Frequently Asked Questions

What is the ThrowableUtil class?
ThrowableUtil is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/ThrowableUtil.java.
Where is ThrowableUtil defined?
ThrowableUtil is defined in common/src/main/java/io/netty/util/internal/ThrowableUtil.java at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free