public static void appendInetAddress(StringBuilder buf, @Nullable InetAddress addr) {
        if (addr == null) {
            buf.append("null");
            return;
        }

        final String str = addr.toString();
        final int slashPos = str.indexOf('/');
        if (slashPos < 0) {
            // Slash is not found; append as-is.
            buf.append(str);
            return;
        }

        if (slashPos == 0) {
            // Slash is the first character; append without the leading slash.
            buf.append(str, 1, str.length());
            return;
        }

        if (slashPos * 2 + 1 != str.length()) {
            // The host name and IP address have different lengths; append as-is.
            buf.append(str);
            return;
        }

        for (int i = 0; i < slashPos; i++) {
            if (str.charAt(i) != str.charAt(i + slashPos + 1)) {
                // The host name and IP address differ; append as-is.
                buf.append(str);
                return;
            }
        }

        // The host name and IP address equals; append only the first part.
        buf.append(str, 0, slashPos);
    }
Formats the given {@link InetAddress}. The difference from {@link InetAddress#toString()} is
that it does not format a host name if it's not available or it's same with the IP address.
core/src/main/java/com/linecorp/armeria/common/util/TextFormatter.java