[ 
https://issues.apache.org/jira/browse/FLINK-33917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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.<init>(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)

Reply via email to