public static boolean isUsingNonDefaultPort(URI uri) {
        String scheme = StringUtils.lowerCase(uri.getScheme());
        int port = uri.getPort();

        if (port <= 0) return false;
        if (scheme.equals("http") && port == 80) return false;
        if (scheme.equals("https") && port == 443) return false;

        return true;
    }
Returns true if the specified URI is using a non-standard port (i.e. any
port other than 80 for HTTP URIs or any port other than 443 for HTTPS
URIs).

@param uri

@return True if the specified URI is using a non-standard port, otherwise
        false.
aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java