private void decompose() {
        java.net.URI neturi = java.net.URI.create(uri).normalize();

        scheme = neturi.getScheme();

        host = neturi.getHost();
        boolean portAlreadyParsed = false;

        // No host if the host contains underscores
        if (host == null) {
            host = neturi.getAuthority();
            if (host != null) {
                int colonPos = host.lastIndexOf(":");
                if (!scheme.equals("file") && colonPos > -1) {
                    //we probably have an (illegal) URI of type http://under_score.com:5000/
                    try {
                        port = Integer.parseInt(host.substring(colonPos + 1));
                        host = host.substring(0, colonPos);
                        portAlreadyParsed = true;
                    } catch (NumberFormatException nfe) {
                        //empty
                    }
                }
            }
        }

        if ("file".equalsIgnoreCase(scheme)) {
            if (host == null) {
                host = "localhost";
            } else {
                host = repairWindowsDrive(host, uri);
            }
        }
        if (host == null) {
            throw new IllegalArgumentException(
                    "A complete uri must specify a host");
        }
        if (!portAlreadyParsed) {
            port = neturi.getPort();
        }
        rest = (neturi.getRawPath() != null ? neturi.getRawPath() : "")
                + (neturi.getRawQuery() != null
                        ? ("?" + neturi.getRawQuery())
                        : "")
                        + (neturi.getRawFragment() != null
                                ? ("#" + neturi.getRawFragment())
                                : "");
    }
Decomposes this uri into scheme, host, port and rest.
vespajlib/src/main/java/com/yahoo/net/URI.java