public static Endpoint fromURL()

in src/main/java/software/amazon/cloudwatchlogs/emf/sinks/Endpoint.java [39:68]


    public static Endpoint fromURL(String endpoint) {
        URI parsedURI = null;

        try {
            parsedURI = new URI(endpoint);
        } catch (URISyntaxException ex) {
            log.warn("Failed to parse the endpoint: {} ", endpoint);
            return DEFAULT_TCP_ENDPOINT;
        }

        if (parsedURI.getHost() == null
                || parsedURI.getPort() < 0
                || parsedURI.getScheme() == null) {
            return DEFAULT_TCP_ENDPOINT;
        }

        Protocol protocol;
        try {
            protocol = Protocol.getProtocol(parsedURI.getScheme());
        } catch (IllegalArgumentException e) {
            log.warn(
                    "Unsupported protocol: {}. Would use default endpoint: {}",
                    parsedURI.getScheme(),
                    DEFAULT_TCP_ENDPOINT);

            return DEFAULT_TCP_ENDPOINT;
        }

        return new Endpoint(parsedURI.getHost(), parsedURI.getPort(), protocol);
    }