diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java index cf705fd1c..d3d83dff9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java @@ -23,50 +23,50 @@ import java.net.UnknownHostException; import java.util.Locale; /** - * Rob Bygrave: This is a copy of the google guava InetAddresses class + * Rob Bygrave: This is a copy of the google guava InetAddresses class * with some features removed. - * - * + *

+ *

* Static utility methods pertaining to {@link InetAddress} instances. - * + *

*

Important note: Unlike {@code InetAddress.getByName()}, the * methods of this class never cause DNS services to be accessed. For * this reason, you should prefer these methods as much as possible over * their JDK equivalents whenever you are expecting to handle only * IP address string literals -- there is no blocking DNS penalty for a * malformed string. - * + *

*

This class hooks into the {@code sun.net.util.IPAddressUtil} class * to make use of the {@code textToNumericFormatV4} and * {@code textToNumericFormatV6} methods directly as a means to avoid * accidentally traversing all nameservices (it can be vitally important * to avoid, say, blocking on DNS at times). - * + *

*

When dealing with {@link Inet4Address} and {@link Inet6Address} * objects as byte arrays (vis. {@code InetAddress.getAddress()}) they * are 4 and 16 bytes in length, respectively, and represent the address * in network byte order. - * + *

*

Examples of IP addresses and their byte representations: *

- * + *

*

A few notes about IPv6 "IPv4 mapped" addresses and their observed * use in Java. *

@@ -77,13 +77,13 @@ import java.util.Locale; * these "mapped" addresses were never supposed to be seen on the * wire. That assumption was dropped, some say mistakenly, in later * RFCs with the apparent aim of making IPv4-to-IPv6 transition simpler. - * + *

*

Technically one can create a 128bit IPv6 address with the wire * format of a "mapped" address, as shown above, and transmit it in an * IPv6 packet header. However, Java's InetAddress creation methods * appear to adhere doggedly to the original intent of the "mapped" * address: all "mapped" addresses return {@link Inet4Address} objects. - * + *

*

For added safety, it is common for IPv6 network operators to filter * all packets where either the source or destination address appears to * be a "compat" or "mapped" address. Filtering suggestions usually @@ -91,44 +91,44 @@ import java.util.Locale; * in the invalid range {@code ::/3}, which includes both of these bizarre * address formats. For more information on "bogons", including lists * of IPv6 bogon space, see: - * + *

*

* * @author Erik Kline * @since 5 */ -//@Beta public final class ConvertInetAddresses { private static final int IPV4_PART_COUNT = 4; private static final int IPV6_PART_COUNT = 8; - private ConvertInetAddresses() {} + private ConvertInetAddresses() { + } /** * Returns the {@link InetAddress} having the given string * representation. - * + *

*

This deliberately avoids all nameservice lookups (e.g. no DNS). * * @param ipString {@code String} containing an IPv4 or IPv6 string literal, * e.g. {@code "192.168.0.1"} or {@code "2001:db8::1"} * @return {@link InetAddress} representing the argument * @throws IllegalArgumentException if the argument is not a valid - * IP string literal + * IP string literal */ public static InetAddress forString(String ipString) { byte[] addr = textToNumericFormatV4(ipString); @@ -299,19 +299,19 @@ public final class ConvertInetAddresses { /** * Returns the string representation of an {@link InetAddress} suitable * for inclusion in a URI. - * + *

*

For IPv4 addresses, this is identical to * {@link InetAddress#getHostAddress()}, but for IPv6 addresses it * surrounds this text with square brackets; for example * {@code "[2001:db8::1]"}. - * + *

*

Per section 3.2.2 of * http://tools.ietf.org/html/rfc3986, + * href="http://tools.ietf.org/html/rfc3986#section-3.2.2" + * >http://tools.ietf.org/html/rfc3986, * a URI containing an IPv6 string literal is of the form * {@code "http://[2001:db8::1]:8888/index.html"}. - * + *

*

Use of either {@link InetAddress#getHostAddress()} or this * method is recommended over {@link InetAddress#toString()} when an * IP address string literal is desired. This is because @@ -331,22 +331,21 @@ public final class ConvertInetAddresses { /** * Returns an InetAddress representing the literal IPv4 or IPv6 host * portion of a URL, encoded in the format specified by RFC 3986 section 3.2.2. - * + *

*

This function is similar to {@link ConvertInetAddresses#forString(String)}, * however, it requires that IPv6 addresses are surrounded by square brackets. - * + *

*

This function is the inverse of * {@link ConvertInetAddresses#toUriString(java.net.InetAddress)}. * * @param hostAddr A RFC 3986 section 3.2.2 encoded IPv4 or IPv6 address * @return an InetAddress representing the address in {@code hostAddr} * @throws IllegalArgumentException if {@code hostAddr} is not a valid - * IPv4 address, or IPv6 address surrounded by square brackets + * IPv4 address, or IPv6 address surrounded by square brackets */ public static InetAddress forUriString(String hostAddr) { - //Preconditions.checkNotNull(hostAddr); - //Preconditions.checkArgument(hostAddr.length() > 0, "host string is empty"); - InetAddress retval = null; + + InetAddress retval; // IPv4 address? try {