Map<String, String> describeNetworkInterfaces(List<String> privateAddresses, AwsCredentials credentials) {
        if (privateAddresses.isEmpty()) {
            return Collections.emptyMap();
        }
        try {
            Map<String, String> attributes = createAttributesDescribeNetworkInterfaces(privateAddresses);
            Map<String, String> headers = createHeaders(attributes, credentials);
            String response = callAwsService(attributes, headers);
            return parseDescribeNetworkInterfaces(response);
        } catch (Exception e) {
            LOGGER.finest(e);
            // Log warning only once.
            if (!isNoPublicIpAlreadyLogged) {
                LOGGER.warning("Cannot fetch the public IPs of ECS Tasks. You won't be able to use "
                        + "Hazelcast Smart Client from outside of this VPC.");
                isNoPublicIpAlreadyLogged = true;
            }

            Map<String, String> map = new HashMap<>();
            privateAddresses.forEach(k -> map.put(k, null));
            return map;
        }
    }
@Test
    public void describeNetworkInterfacesException() {
        // given
        List<String> privateAddresses = asList("10.0.1.207", "10.0.1.82");

        String requestUrl = "/?Action=DescribeNetworkInterfaces"
                + "&Filter.1.Name=addresses.private-ip-address"
                + "&Filter.1.Value.1=10.0.1.207"
                + "&Filter.1.Value.2=10.0.1.82"
                + "&Version=2016-11-15";

        //language=XML
        String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<DescribeNetworkInterfacesResponse xmlns=\"http://ec2.amazonaws.com/doc/2016-11-15/\">\n"
                + "    <requestId>21bc9f93-2196-4107-87a3-9e5b2b3f29d9</requestId>\n"
                + "    <networkInterfaceSet>\n"
                + "        <item>\n"
                + "            <availabilityZone>eu-central-1a</availabilityZone>\n"
                + "            <privateIpAddress>10.0.1.207</privateIpAddress>\n"
                + "            <association>\n"
                + "                <publicIp>54.93.217.194</publicIp>\n"
                + "            </association>\n"
                + "        </item>\n"
                + "        <item>\n"
                + "            <availabilityZone>eu-central-1a</availabilityZone>\n"
                + "            <privateIpAddress>10.0.1.82</privateIpAddress>\n"
                + "            <association>\n"
                + "                <publicIp>35.156.192.128</publicIp>\n"
                + "            </association>\n"
                + "        </item>\n"
                + "    </networkInterfaceSet>\n"
                + "</DescribeNetworkInterfacesResponse>";

        stubFor(get(urlEqualTo(requestUrl))
                .withHeader("X-Amz-Date", equalTo("20200403T102518Z"))
                .withHeader("Authorization", equalTo(AUTHORIZATION_HEADER))
                .withHeader("X-Amz-Security-Token", equalTo(TOKEN))
                .willReturn(aResponse().withStatus(HttpURLConnection.HTTP_INTERNAL_ERROR)));

        // when
        Map<String, String> result = awsEc2Api.describeNetworkInterfaces(privateAddresses, CREDENTIALS);

        // then
        assertEquals(2, result.size());
        assertNull(result.get("10.0.1.207"));
        assertNull(result.get("10.0.1.82"));
    }