Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/2917#discussion_r92626161
--- Diff: flink-core/src/main/java/org/apache/flink/util/NetUtils.java ---
@@ -111,7 +115,51 @@ public static int getAvailablePort() {
//
------------------------------------------------------------------------
// Encoding of IP addresses for URLs
//
------------------------------------------------------------------------
-
+
+ /**
+ * Returns an address in a normalized format for Akka.
+ * When an IPv6 address is specified, it normalizes the IPv6 address to
avoid
+ * complications with the exact URL match policy of Akka.
+ * @param host The hostname, IPv4 or IPv6 address
+ * @return host which will be normalized if it is an IPv6 address
+ */
+ public static String unresolvedHostToNormalizedString(String host) {
+ // Return loopback interface address if host is null
+ // This represents the behavior of {@code InetAddress.getByName
} and RFC 3330
+ if (host == null) {
+ host =
InetAddress.getLoopbackAddress().getHostAddress();
+ } else {
+ host = host.trim().toLowerCase();
+ }
+
+ // normalize and valid address
+ if (IPAddressUtil.isIPv6LiteralAddress(host)) {
+ byte[] ipV6Address =
IPAddressUtil.textToNumericFormatV6(host);
+ host = getIPv6UrlRepresentation(ipV6Address);
+ } else if (!IPAddressUtil.isIPv4LiteralAddress(host)) {
+ // We don't allow these in hostnames
+ Preconditions.checkArgument(!host.startsWith("."));
+ Preconditions.checkArgument(!host.endsWith("."));
+ Preconditions.checkArgument(!host.contains(":"));
--- End diff --
Maybe we could add a clarifying error message here for the user.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---