@VisibleForTesting
    @Nullable
    static String getHostAddress(InetSocketAddress socketAddress) {
        InetAddress address = socketAddress.getAddress();
        if (address instanceof Inet6Address) {
            // Strip the scope from the address since some other classes choke on it.
            // TODO(carl-mastrangelo): Consider adding this back in once issues like
            // https://github.com/google/guava/issues/2587 are fixed.
            try {
                return InetAddress.getByAddress(address.getAddress()).getHostAddress();
            } catch (UnknownHostException e) {
                throw new RuntimeException(e);
            }
        } else if (address instanceof Inet4Address) {
            return address.getHostAddress();
        } else {
            assert address == null;
            return null;
        }
    }
@Test
    void mapsIpv4AddressFromIpv6Address() throws Exception {
        // Can't think of a reason why this would ever come up, but testing it just in case.
        // ::ffff:127.0.0.1
        Inet6Address address = Inet6Address.getByAddress(
                "localhost", new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0xFF, (byte) 0xFF, 127, 0, 0, 1}, -1);
        assertEquals(0, address.getScopeId());

        String addressString = SourceAddressChannelHandler.getHostAddress(new InetSocketAddress(address, 8080));

        assertEquals("127.0.0.1", addressString);
    }