[jira] [Commented] (FLINK-33917) IllegalArgumentException: hostname can't be null
[ https://issues.apache.org/jira/browse/FLINK-33917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17799701#comment-17799701 ] Maximilian Michels commented on FLINK-33917: {{new URI("123-test").getHost()}} returns null. I’m not 100% sure this is a JDK bug. There may be some ambiguity when resolving URIs without all spec parts. But let’s see what upstream says. > IllegalArgumentException: hostname can't be null > > > Key: FLINK-33917 > URL: https://issues.apache.org/jira/browse/FLINK-33917 > Project: Flink > Issue Type: Bug > Components: Kubernetes Operator >Reporter: Tom >Priority: Major > Labels: pull-request-available > > In certain scenarios, if the hostname contains certain characters it will > throw an exception when it tries to initialize the `InetSocketAddress` > > {code:java} > java.lang.IllegalArgumentException: hostname can't be null at > java.base/java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) > at > java.base/java.net.InetSocketAddress.(InetSocketAddress.java:216) {code} > > [https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java|https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java#L236] > > {code:java} > @Override > public boolean isJobManagerPortReady(Configuration config) { > final URI uri; > try (var clusterClient = getClusterClient(config)) { > uri = URI.create(clusterClient.getWebInterfaceURL()); > } catch (Exception ex) { > throw new FlinkRuntimeException(ex); > } > SocketAddress socketAddress = new InetSocketAddress(uri.getHost(), > uri.getPort()); > Socket socket = new Socket(); > try { > socket.connect(socketAddress, 1000); > socket.close(); > return true; > } catch (IOException e) { > return false; > } > } > {code} > > Here's a simple test to reproduce > > URL > {code:java} > @ParameterizedTest > @ValueSource( > strings = {"http://127.0.0.1:8081;, "http://123-dev:8081;, > "http://dev-test.abc:8081;, "http://dev-test.1a:8081;, > "http://dev-test.abc01:8081"}) > void testURLAddresses(String inputAddress) { > assertDoesNotThrow( > () -> { > final URL url = new URL(inputAddress); > new InetSocketAddress(url.getHost(), url.getPort()); > }); > } {code} > > URI > > {code:java} > @ParameterizedTest > @ValueSource( > strings = {"http://127.0.0.1:8081;, "http://123-dev:8081;, > "http://dev-test.abc:8081;, "http://dev-test.1a:8081;, > "http://dev-test.abc01:8081"}) > void testURIAddresses(String inputAddress) { > assertDoesNotThrow( > () -> { > final URI uri = new URI(inputAddress); > new InetSocketAddress(uri.getHost(), uri.getPort()); > }); > } {code} > > All test cases past except for "http://dev-test.1a:8081; which is a valid > flink host url, but not a valid URI > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-33917) IllegalArgumentException: hostname can't be null
[ https://issues.apache.org/jira/browse/FLINK-33917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17799686#comment-17799686 ] Tom commented on FLINK-33917: - I've also raised this as a JDK bug in the mean time https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8322667 > IllegalArgumentException: hostname can't be null > > > Key: FLINK-33917 > URL: https://issues.apache.org/jira/browse/FLINK-33917 > Project: Flink > Issue Type: Bug > Components: Kubernetes Operator >Reporter: Tom >Priority: Major > Labels: pull-request-available > > In certain scenarios, if the hostname contains certain characters it will > throw an exception when it tries to initialize the `InetSocketAddress` > > {code:java} > java.lang.IllegalArgumentException: hostname can't be null at > java.base/java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) > at > java.base/java.net.InetSocketAddress.(InetSocketAddress.java:216) {code} > > [https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java|https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java#L236] > > {code:java} > @Override > public boolean isJobManagerPortReady(Configuration config) { > final URI uri; > try (var clusterClient = getClusterClient(config)) { > uri = URI.create(clusterClient.getWebInterfaceURL()); > } catch (Exception ex) { > throw new FlinkRuntimeException(ex); > } > SocketAddress socketAddress = new InetSocketAddress(uri.getHost(), > uri.getPort()); > Socket socket = new Socket(); > try { > socket.connect(socketAddress, 1000); > socket.close(); > return true; > } catch (IOException e) { > return false; > } > } > {code} > > Here's a simple test to reproduce > > URL > {code:java} > @ParameterizedTest > @ValueSource( > strings = {"http://127.0.0.1:8081;, "http://123-dev:8081;, > "http://dev-test.abc:8081;, "http://dev-test.1a:8081;, > "http://dev-test.abc01:8081"}) > void testURLAddresses(String inputAddress) { > assertDoesNotThrow( > () -> { > final URL url = new URL(inputAddress); > new InetSocketAddress(url.getHost(), url.getPort()); > }); > } {code} > > URI > > {code:java} > @ParameterizedTest > @ValueSource( > strings = {"http://127.0.0.1:8081;, "http://123-dev:8081;, > "http://dev-test.abc:8081;, "http://dev-test.1a:8081;, > "http://dev-test.abc01:8081"}) > void testURIAddresses(String inputAddress) { > assertDoesNotThrow( > () -> { > final URI uri = new URI(inputAddress); > new InetSocketAddress(uri.getHost(), uri.getPort()); > }); > } {code} > > All test cases past except for "http://dev-test.1a:8081; which is a valid > flink host url, but not a valid URI > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-33917) IllegalArgumentException: hostname can't be null
[ https://issues.apache.org/jira/browse/FLINK-33917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17799677#comment-17799677 ] Tom commented on FLINK-33917: - Actually uri("123-test") does work. The issue here is the '.' followed by a number uri("123-test.abc") works, but uri("dev-test.01") does not. Here's a test case you can run @ParameterizedTest @ValueSource( strings = \{"http://127.0.0.1:8081;, "http://123-dev:8081;, "http://dev-test.abc:8081;, "http://dev-test.1a:8081;, "http://dev-test.abc01:8081"}) void testURIAddresses(String inputAddress) { assertDoesNotThrow( () -> { final URI url = new URI(inputAddress); new InetSocketAddress(url.getHost(), url.getPort()); }); } > IllegalArgumentException: hostname can't be null > > > Key: FLINK-33917 > URL: https://issues.apache.org/jira/browse/FLINK-33917 > Project: Flink > Issue Type: Bug > Components: Kubernetes Operator >Reporter: Tom >Priority: Major > Labels: pull-request-available > > In certain scenarios, if the hostname contains certain characters it will > throw an exception when it tries to initialize the `InetSocketAddress` > > {code:java} > java.lang.IllegalArgumentException: hostname can't be null at > java.base/java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) > at > java.base/java.net.InetSocketAddress.(InetSocketAddress.java:216) {code} > > [https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java|https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java#L236] > > {code:java} > @Override > public boolean isJobManagerPortReady(Configuration config) { > final URI uri; > try (var clusterClient = getClusterClient(config)) { > uri = URI.create(clusterClient.getWebInterfaceURL()); > } catch (Exception ex) { > throw new FlinkRuntimeException(ex); > } > SocketAddress socketAddress = new InetSocketAddress(uri.getHost(), > uri.getPort()); > Socket socket = new Socket(); > try { > socket.connect(socketAddress, 1000); > socket.close(); > return true; > } catch (IOException e) { > return false; > } > } > {code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-33917) IllegalArgumentException: hostname can't be null
[ https://issues.apache.org/jira/browse/FLINK-33917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17799352#comment-17799352 ] Maximilian Michels commented on FLINK-33917: The description doesn’t describe under which circumstances the host name can be parsed as null. One example is {{new URI("123-test")}} which will return a null host name because the string is parsed as a URI path. Flink itself returns a stringified URL object. So using URL instead works fine. > IllegalArgumentException: hostname can't be null > > > Key: FLINK-33917 > URL: https://issues.apache.org/jira/browse/FLINK-33917 > Project: Flink > Issue Type: Bug > Components: Kubernetes Operator >Reporter: Tom >Priority: Major > Labels: pull-request-available > > In certain scenarios, if the hostname contains certain characters it will > throw an exception when it tries to initialize the `InetSocketAddress` > > {code:java} > java.lang.IllegalArgumentException: hostname can't be null at > java.base/java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) > at > java.base/java.net.InetSocketAddress.(InetSocketAddress.java:216) {code} > > [https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java|https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java#L236] > > {code:java} > @Override > public boolean isJobManagerPortReady(Configuration config) { > final URI uri; > try (var clusterClient = getClusterClient(config)) { > uri = URI.create(clusterClient.getWebInterfaceURL()); > } catch (Exception ex) { > throw new FlinkRuntimeException(ex); > } > SocketAddress socketAddress = new InetSocketAddress(uri.getHost(), > uri.getPort()); > Socket socket = new Socket(); > try { > socket.connect(socketAddress, 1000); > socket.close(); > return true; > } catch (IOException e) { > return false; > } > } > {code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)