Home / Class/ Errors Class — netty Architecture

Errors Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed["Errors"]
  60e7c91e_73b4_5871_d5a9_09808c81c2cd["Errors.java"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|defined in| 60e7c91e_73b4_5871_d5a9_09808c81c2cd
  86663d14_9cde_cf7b_b3e1_a55d58d14419["handleConnectErrno()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| 86663d14_9cde_cf7b_b3e1_a55d58d14419
  9154c513_922d_4ddc_8b31_6a8d722d3113["throwConnectException()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| 9154c513_922d_4ddc_8b31_6a8d722d3113
  07032ac3_c870_225f_22f4_8b78e639f347["String()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| 07032ac3_c870_225f_22f4_8b78e639f347
  5075d112_701f_ac10_d707_06cde67a40a8["IOException()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| 5075d112_701f_ac10_d707_06cde67a40a8
  df1a8e14_972c_71b4_f6bb_3c75ca5a781e["NativeIoException()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| df1a8e14_972c_71b4_f6bb_3c75ca5a781e
  d5b50b0c_60fc_262c_54c0_df7c98627d48["ioResult()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| d5b50b0c_60fc_262c_54c0_df7c98627d48
  3910b372_34ef_0dad_b46f_34df7ed36ad1["Errors()"]
  93a42678_e9fc_3a0e_6c3b_8f2b742961ed -->|method| 3910b372_34ef_0dad_b46f_34df7ed36ad1

Relationship Graph

Source Code

transport-native-unix-common/src/main/java/io/netty/channel/unix/Errors.java lines 48–223

public final class Errors {
    // As all our JNI methods return -errno on error we need to compare with the negative errno codes.
    public static final int ERRNO_ENOENT_NEGATIVE = -errnoENOENT();
    public static final int ERRNO_ENOTCONN_NEGATIVE = -errnoENOTCONN();
    public static final int ERRNO_EBADF_NEGATIVE = -errnoEBADF();
    public static final int ERRNO_EPIPE_NEGATIVE = -errnoEPIPE();
    public static final int ERRNO_ECONNRESET_NEGATIVE = -errnoECONNRESET();
    public static final int ERRNO_EAGAIN_NEGATIVE = -errnoEAGAIN();
    public static final int ERRNO_EWOULDBLOCK_NEGATIVE = -errnoEWOULDBLOCK();
    public static final int ERRNO_EINPROGRESS_NEGATIVE = -errnoEINPROGRESS();
    public static final int ERROR_ECONNREFUSED_NEGATIVE = -errorECONNREFUSED();
    public static final int ERROR_EISCONN_NEGATIVE = -errorEISCONN();
    public static final int ERROR_EALREADY_NEGATIVE = -errorEALREADY();
    public static final int ERROR_ENETUNREACH_NEGATIVE = -errorENETUNREACH();
    public static final int ERROR_EHOSTUNREACH_NEGATIVE = -errorEHOSTUNREACH();

    /**
     * Holds the mappings for errno codes to String messages.
     * This eliminates the need to call back into JNI to get the right String message on an exception
     * and thus is faster.
     *
     * Choose an array length which should give us enough space in the future even when more errno codes
     * will be added.
     */
    private static final String[] ERRORS = new String[2048];

    /**
     * <strong>Internal usage only!</strong>
     */
    public static final class NativeIoException extends IOException {
        private static final long serialVersionUID = 8222160204268655526L;
        private final int expectedErr;
        private final boolean fillInStackTrace;

        public NativeIoException(String method, int expectedErr) {
            this(method, expectedErr, true);
        }

        public NativeIoException(String method, int expectedErr, boolean fillInStackTrace) {
            super(method + "(..) failed with error(" + expectedErr + "): " + errnoString(-expectedErr));
            this.expectedErr = expectedErr;
            this.fillInStackTrace = fillInStackTrace;
        }

        public int expectedErr() {
            return expectedErr;
        }

        @Override
        public synchronized Throwable fillInStackTrace() {
            if (fillInStackTrace) {
                return super.fillInStackTrace();
            }
            return this;
        }
    }

    static final class NativeConnectException extends ConnectException {
        private static final long serialVersionUID = -5532328671712318161L;
        private final int expectedErr;
        NativeConnectException(String method, int expectedErr) {
            super(method + "(..) failed with error(" + expectedErr + "):" + errnoString(-expectedErr));
            this.expectedErr = expectedErr;
        }

        int expectedErr() {
            return expectedErr;
        }
    }

    static {
        for (int i = 0; i < ERRORS.length; i++) {
            // This is ok as strerror returns 'Unknown error i' when the message is not known.
            ERRORS[i] = strError(i);
        }
    }

    public static boolean handleConnectErrno(String method, int err) throws IOException {
        if (err == ERRNO_EINPROGRESS_NEGATIVE || err == ERROR_EALREADY_NEGATIVE) {
            // connect not complete yet need to wait for EPOLLOUT event.
            // EALREADY has been observed when using tcp fast open on centos8.

Frequently Asked Questions

What is the Errors class?
Errors is a class in the netty codebase, defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/Errors.java.
Where is Errors defined?
Errors is defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/Errors.java at line 48.

Analyze Your Own Codebase

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

Try Supermodel Free