Home / Function/ Throwable() — netty Function Reference

Throwable() — netty Function Reference

Architecture documentation for the Throwable() function in DefaultDnsCache.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  73830653_e40d_ad66_cdf5_7b21a1ebada2["Throwable()"]
  6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f["DefaultDnsCache"]
  73830653_e40d_ad66_cdf5_7b21a1ebada2 -->|defined in| 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f
  style 73830653_e40d_ad66_cdf5_7b21a1ebada2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java lines 262–291

    private static Throwable copyThrowable(Throwable error) {
        if (error.getClass() == UnknownHostException.class) {
            // Fast-path as this is the only type of Throwable that our implementation ever add to the cache.
            UnknownHostException copy = new UnknownHostException(error.getMessage()) {
                @Override
                public Throwable fillInStackTrace() {
                    // noop.
                    return this;
                }
            };
            copy.initCause(error.getCause());
            copy.setStackTrace(error.getStackTrace());
            return copy;
        }

        try {
            // Throwable is Serializable so lets just do a deep copy.
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
                oos.writeObject(error);
            }

            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            try (ObjectInputStream ois = new ObjectInputStream(bais)) {
                return (Throwable) ois.readObject();
            }
        } catch (IOException | ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }
    }

Subdomains

Frequently Asked Questions

What does Throwable() do?
Throwable() is a function in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java.
Where is Throwable() defined?
Throwable() is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java at line 262.

Analyze Your Own Codebase

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

Try Supermodel Free