public static String sanitizeAddress(InetSocketAddress addr)
    {
        Preconditions.checkArgument( !addr.isUnresolved(), "Unresolved address" );
        String string = addr.getAddress().getHostAddress();

        // Remove IPv6 scope if present
        if ( addr.getAddress() instanceof Inet6Address )
        {
            int strip = string.indexOf( '%' );
            return ( strip == -1 ) ? string : string.substring( 0, strip );
        } else
        {
            return string;
        }
    }
@Test
    public void testScope()
    {
        InetSocketAddress addr = new InetSocketAddress( "0:0:0:0:0:0:0:1%0", 25577 );
        assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr ) );

        InetSocketAddress addr2 = new InetSocketAddress( "0:0:0:0:0:0:0:1", 25577 );
        assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr2 ) );
    }