Check if the strings Grpc url is valid

@param url
@return Return the exception that indicates the error or null if ok.
434270
public static Exception checkGrpcUrl(String url) {
        try {

            parseGrpcUrl(url);
            return null;

        } catch (Exception e) {
            return e;
        }
    }
187402
private static URL safeURL(String urlString) throws ClassNotFoundException
	{
		try
		{
			return new URL(urlString);
		}
		catch (MalformedURLException exception)
		{
			throw new ClassNotFoundException(exception.getMessage());
		}
	}
219722
@Nonnull
  public static StringBuffer getRequestRequestURL (@Nullable final HttpServletRequest aRequest)
  {
    StringBuffer ret = null;
    if (aRequest != null)
      try
      {
        ret = aRequest.getRequestURL ();
      }
      catch (final Exception ex)
      {
        // fall through
        if (isLogExceptions ())
          if (LOGGER.isWarnEnabled ())
            LOGGER.warn ("[ServletHelper] Failed to determine request URL of HTTP request", ex);
      }
    return ret != null ? ret : new StringBuffer ();
  }
177613
private boolean isInvalidURL(String url) {
        try {
            final URL u = new URL(url);
            u.toURI();
        } catch (MalformedURLException | URISyntaxException e) {
            LOGGER.trace("URL is invalid: {}", url);
            return true;
        }
        return false;
    }
122599
public static String slurpURLNoExceptions(URL u) {
    try {
      return slurpURL(u);
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
320404
private boolean checkUrl(String url) {
        try {
            URI uri = new URI(url);
            return uri.isAbsolute();
        } catch (URISyntaxException e) {
            return false;
        }
    }
1352563
public int get(String url) throws Exception {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(url)
                .build();
        try(Response response = client.newCall(request).execute()) {
            if (!response.isSuccessful()) {
                throw new Exception("error sending HTTP GET to this URL: " + url);
            }
            return response.code();
        }
    }
969449
public static HttpUrl parse(String url) {
        Builder builder = new Builder();
        Builder.ParseResult result = builder.parse(null, url);
        return result == Builder.ParseResult.SUCCESS ? builder.build() : null;
    }
742007
public static String extractServerUrl(String url)
    {
        int rightIndex = url.length();
        if (url.lastIndexOf("/") != -1) { rightIndex = url.lastIndexOf("/"); }
        else if (url.lastIndexOf(":") != -1) { rightIndex = url.lastIndexOf(":"); }
        
        StringBuilder baseUrl = new StringBuilder();
        baseUrl.append(url.substring(0, rightIndex));

        // TODO This next line is pretty ugly, but it works for nearly every postgresql server.
        // If we have to add another exception to this for another database server, then I highly recommend refactoring this to a more elegant solution.
        if (POSTGRESQL.equals(databaseType(url))) { baseUrl.append("/postgres"); }

        int optionsIndex = url.indexOf("?");
        if (optionsIndex == -1) { optionsIndex = url.indexOf(";"); }
        if (optionsIndex != -1) { baseUrl.append(url.substring(optionsIndex)); }

        return baseUrl.toString();
    }
806393
private Snippet checkValidSnippet(Snippet sn) {
        if (sn == null) {
            throw new NullPointerException(messageFormat("jshell.exc.null"));
        } else {
            if (sn.key().state() != this) {
                throw new IllegalArgumentException(messageFormat("jshell.exc.alien"));
            }
            return sn;
        }
    }
782382
public static boolean isUrl(String urlAsString) {
        if (urlAsString != null && urlAsString.trim().length() > 0) {
            try {
                new URL(urlAsString);
                return true;
            } catch (MalformedURLException murle) {
                return false;
            }
        }

        return false;
    }
206786
public static HttpResponse executeGet(final String url) {
        try {
            return executeGet(url, null, null, new LinkedHashMap<>());
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
1257989
public static void browse(String url) throws Exception {
        //获取操作系统的名字
        String osName = System.getProperty("os.name", "");
        if (osName.startsWith("Mac OS")) {
            //苹果的打开方式
            Class fileMgr = Class.forName("com.apple.eio.FileManager");
            Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[]{String.class});
            openURL.invoke(null, new Object[]{url});
        } else if (osName.startsWith("Windows")) {
            //windows的打开方式。
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
        } else {
            // Unix or Linux的打开方式
            String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"};
            String browser = null;
            for (int count = 0; count < browsers.length && browser == null; count++) {
                //执行代码，在brower有值后跳出，
                //这里是如果进程创建成功了，==0是表示正常结束。
                if (Runtime.getRuntime().exec(new String[]{"which", browsers[count]}).waitFor() == 0) {
                    browser = browsers[count];
                }
            }
            if (browser == null) {
                throw new Exception("Could not find web browser");
            } else {
                //这个值在上面已经成功的得到了一个进程。
                Runtime.getRuntime().exec(new String[]{browser, url});
            }
        }
    }
1214925
private String getValidURL(String url)
	{
		if (url != null && url.length() > 0)
		{
			// XXX really important that this one happens first!!
			return url.replaceAll("[%]", "%25")
				.replaceAll(" ", "%20")
				.replaceAll("[<]", "%3c")
				.replaceAll("[>]", "%3e")
				.replaceAll("[\"]", "%3f")
			.replaceAll("[#]", "%23")
			.replaceAll("[{]", "%7b")
			.replaceAll("[}]", "%7d")
			.replaceAll("[|]", "%7c")
			.replaceAll("[\\\\]", "%5c") // double check this
													// one :-)
			.replaceAll("[\\^]", "%5e")
			.replaceAll("[~]", "%7e")
			.replaceAll("[\\[]", "%5b")
			.replaceAll("[\\]]", "%5d")
			.replaceAll("[']", "%27")
			.replaceAll("[?]", "%3f");
		}

		return url;

	}
707931
@Then("^we are in page '(.+?)'$")
    public void checkURL(String url) throws Exception {

        if (commonspec.getWebHost() == null) {
            throw new Exception("Web host has not been set");
        }

        if (commonspec.getWebPort() == null) {
            throw new Exception("Web port has not been set");
        }

        String webURL = commonspec.getWebHost() + commonspec.getWebPort();

        assertThat(commonspec.getDriver().getCurrentUrl()).as("We are not in the expected url: " + webURL.toLowerCase() + url)
                .endsWith(webURL.toLowerCase() + url);
    }
925736
public static boolean checkServerConnection(String serverURL) {
        boolean value = false;
        try {
            value = new RetrieveCheckServerConnectionString().execute(serverURL).get();
        } catch (InterruptedException e) {
            QuickUtils.log.e("InterruptedException", e);
        } catch (ExecutionException e) {
            QuickUtils.log.e("ExecutionException", e);
        }
        return value;
    }
556584
@FFDCIgnore(Exception.class)
    private void checkVCAPHost(ServerInfo server) {
        String VCAP_APPLICATION = System.getenv("VCAP_APPLICATION");
        if (VCAP_APPLICATION != null) {
            try {
                JsonNode node = Json.mapper().readValue(VCAP_APPLICATION, JsonNode.class);
                ArrayNode uris = (ArrayNode) node.get("uris");
                if (uris != null && uris.size() > 0 && uris.get(0) != null) {
                    server.setHost(uris.get(0).textValue());
                    if (OpenAPIUtils.isEventEnabled(tc)) {
                        Tr.event(this, tc, "Changed hostPort using VCAP_APPLICATION.  New value: " + server.getHost());
                    }
                }
            } catch (Exception e) {
                if (OpenAPIUtils.isEventEnabled(tc)) {
                    Tr.event(this, tc, "Exception while parsing VCAP_APPLICATION env: " + e.getMessage());
                }
            }
        }
    }