Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-33917

IllegalArgumentException: hostname can't be null

    XMLWordPrintableJSON

Details

    Description

      In certain scenarios, if the hostname contains certain characters it will throw an exception when it tries to initialize the `InetSocketAddress`

       

      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) 

       

      https://github.com/apache/flink-kubernetes-operator/blob/main/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.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;
              }
          }
        

       

      Here's a simple test to reproduce

       

      URL

      @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());
                  });
      } 

       

      URI

       

      @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());
                  });
      }  

       

      All test cases past except for  "http://dev-test.1a:8081" which is a valid flink host url, but not a valid URI

       

      Attachments

        Issue Links

          Activity

            People

              ensctom Tom
              ensctom Tom
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: