private InetSocketAddress toSocketAddress0(int defaultPort) {
        if (isDomainSocket()) {
            final String decodedHost;
            try {
                decodedHost = URLDecoder.decode(host, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // Should never reach here.
                throw new Error(e);
            }

            assert decodedHost.startsWith("unix:") : decodedHost;
            return DomainSocketAddress.of(decodedHost.substring(5)); // Strip "unix:"
        }

        final int port = hasPort() ? this.port : defaultPort;
        if (!hasIpAddr()) {
            return InetSocketAddress.createUnresolved(host, port);
        }

        assert ipAddr != null;
        try {
            return new InetSocketAddress(
                    InetAddress.getByAddress(
                            // Let JDK use the normalized IP address as the host name.
                            isIpAddrOnly() ? null : host,
                            NetUtil.createByteArrayFromIpAddressString(ipAddr)),
                    port);
        } catch (UnknownHostException e) {
            // Should never reach here.
            throw new Error(e);
        }
    }
Converts this endpoint into an {@link InetSocketAddress}. The specified {@code defaultPort} is used
if this endpoint does not have a port number. A {@link DomainSocketAddress} is returned if this
endpoint refers to a Unix domain socket.

@see #hasPort()
@see #isDomainSocket()
core/src/main/java/com/linecorp/armeria/client/Endpoint.java