Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16280

NettyEndpointUriFactory#buildUri() not compatible with Netty endpoint URL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.8.0
    • 3.9.0
    • camel-netty
    • None
    • Unknown

    Description

      Run this jbang script:

      ///usr/bin/env jbang "$0" "$@" ; exit $?
      //DEPS org.apache.camel:camel-core-engine:3.8.0
      //DEPS org.apache.camel:camel-main:3.8.0
      //DEPS org.apache.camel:camel-stream:3.8.0
      //DEPS org.apache.camel:camel-netty:3.8.0
      //DEPS org.slf4j:slf4j-nop:1.7.25
      
      import java.util.*;
      
      import org.apache.camel.*;
      import org.apache.camel.spi.*;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.main.Main;
      import org.apache.camel.component.netty.*;
      
      Main main = new Main();
      main.configure().addRoutesBuilder(new RouteBuilder() {
          @Override
          public void configure() throws Exception {
              EndpointUriFactory factory = getContext().adapt(ExtendedCamelContext.class).getEndpointUriFactory("netty");
              Map<String, Object> config = Map.of(
                  "protocol", "tcp",
                  "host", "localhost",
                  "port", 9999
              );
              String uri = factory.buildUri("netty", config, false);
              System.out.println("uri = " + uri);
              from(uri).to("stream:out");
              //from("netty:tcp://localhost:9999").to("stream:out"); // this is OK
          }
      });
      main.run();
      

      and you'll get the following error:

      $ ./camel-netty.jsh 
      uri = netty:tcp:localhost:9999
      Exception java.lang.IllegalArgumentException: hostname can't be null
            at InetSocketAddress.checkHost (InetSocketAddress.java:149)
            at InetSocketAddress.<init> (InetSocketAddress.java:216)
            at SingleTCPNettyServerBootstrapFactory.startServerBootstrap (SingleTCPNettyServerBootstrapFactory.java:184)
            at SingleTCPNettyServerBootstrapFactory.doStart (SingleTCPNettyServerBootstrapFactory.java:113)
            at BaseService.start (BaseService.java:115)
            at ServiceHelper.startService (ServiceHelper.java:84)
            at NettyConsumer.doStart (NettyConsumer.java:75)
            at BaseService.start (BaseService.java:115)
            at AbstractCamelContext.startService (AbstractCamelContext.java:3446)
            at InternalRouteStartupManager.doStartOrResumeRouteConsumers (InternalRouteStartupManager.java:401)
            at InternalRouteStartupManager.doStartRouteConsumers (InternalRouteStartupManager.java:319)
            at InternalRouteStartupManager.safelyStartRouteServices (InternalRouteStartupManager.java:213)
            at InternalRouteStartupManager.doStartOrResumeRoutes (InternalRouteStartupManager.java:147)
            at AbstractCamelContext.doStartCamel (AbstractCamelContext.java:3150)
            at AbstractCamelContext.doStartContext (AbstractCamelContext.java:2846)
            at AbstractCamelContext.doStart (AbstractCamelContext.java:2797)
            at BaseService.start (BaseService.java:115)
            at AbstractCamelContext.start (AbstractCamelContext.java:2492)
            at Main.doStart (Main.java:116)
            at BaseService.start (BaseService.java:115)
            at MainSupport.run (MainSupport.java:68)
            at (#9:1)
      

      This issue is the root cause of this CKC issue:
      https://github.com/apache/camel-kafka-connector/issues/924

      Attachments

        1. camel-netty.jsh
          1 kB
          Tadayoshi Sato

        Issue Links

          Activity

            People

              tadayosi Tadayoshi Sato
              tadayosi Tadayoshi Sato
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: