@Test (expected = IllegalArgumentException.class) public void shouldRequireExplicitPortOnIpv4() { ResolutionUtils.parseBindAddress("127.0.0.1"); }
public static InetSocketAddress parseBindAddress(String bindAddress) { Exception cause = null; try { if (!bindAddress.contains(":")) { return new InetSocketAddress(Integer.parseInt(bindAddress)); } Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT); Matcher matcher = pattern.matcher(bindAddress); if (matcher.find()) { return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2))); } String tmpAddress = "scheme: URI uri = URI.create(tmpAddress); if (uri.getPort() != -1) { return new InetSocketAddress(uri.getHost(), uri.getPort()); } } catch (Exception e) { cause = e; } throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format.", bindAddress), cause); }
ResolutionUtils { public static InetSocketAddress parseBindAddress(String bindAddress) { Exception cause = null; try { if (!bindAddress.contains(":")) { return new InetSocketAddress(Integer.parseInt(bindAddress)); } Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT); Matcher matcher = pattern.matcher(bindAddress); if (matcher.find()) { return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2))); } String tmpAddress = "scheme: URI uri = URI.create(tmpAddress); if (uri.getPort() != -1) { return new InetSocketAddress(uri.getHost(), uri.getPort()); } } catch (Exception e) { cause = e; } throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format.", bindAddress), cause); } }
ResolutionUtils { public static InetSocketAddress parseBindAddress(String bindAddress) { Exception cause = null; try { if (!bindAddress.contains(":")) { return new InetSocketAddress(Integer.parseInt(bindAddress)); } Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT); Matcher matcher = pattern.matcher(bindAddress); if (matcher.find()) { return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2))); } String tmpAddress = "scheme: URI uri = URI.create(tmpAddress); if (uri.getPort() != -1) { return new InetSocketAddress(uri.getHost(), uri.getPort()); } } catch (Exception e) { cause = e; } throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format.", bindAddress), cause); } private  ResolutionUtils(); }
ResolutionUtils { public static InetSocketAddress parseBindAddress(String bindAddress) { Exception cause = null; try { if (!bindAddress.contains(":")) { return new InetSocketAddress(Integer.parseInt(bindAddress)); } Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT); Matcher matcher = pattern.matcher(bindAddress); if (matcher.find()) { return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2))); } String tmpAddress = "scheme: URI uri = URI.create(tmpAddress); if (uri.getPort() != -1) { return new InetSocketAddress(uri.getHost(), uri.getPort()); } } catch (Exception e) { cause = e; } throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format.", bindAddress), cause); } private  ResolutionUtils(); static Collection<InetAddress> getAllByName(String host, boolean allowIPv6); static InetSocketAddress parseBindAddress(String bindAddress); }
ResolutionUtils { public static InetSocketAddress parseBindAddress(String bindAddress) { Exception cause = null; try { if (!bindAddress.contains(":")) { return new InetSocketAddress(Integer.parseInt(bindAddress)); } Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT); Matcher matcher = pattern.matcher(bindAddress); if (matcher.find()) { return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2))); } String tmpAddress = "scheme: URI uri = URI.create(tmpAddress); if (uri.getPort() != -1) { return new InetSocketAddress(uri.getHost(), uri.getPort()); } } catch (Exception e) { cause = e; } throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format.", bindAddress), cause); } private  ResolutionUtils(); static Collection<InetAddress> getAllByName(String host, boolean allowIPv6); static InetSocketAddress parseBindAddress(String bindAddress);  }