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

Unreachable consul leads to NPE in CombinedServiceDiscovery

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.9.0
    • Fix Version/s: 3.10.0
    • Component/s: camel-consul
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      When com.orbitz.consul.AgentClient cannot ping Consul in its ping() method during client creation, no exception is thrown in the exception handler of Suppliers.memorize defined in the ConsulServiceDiscovery ctor, rather the exception only gets wrapped and then nothing is done with it:

      this.client = Suppliers.memorize(() -> configuration.createConsulClient(getCamelContext()),
              e -> RuntimeCamelException.wrapRuntimeCamelException(e)); 

      That has the consequence that ConsulServiceDiscovery.getServices throws a NPE, which in turn kills the loop early in CombinedServiceDiscovery where all service discoveries are being asked for their services list.

      The client supplier function gets called lazily when getServices is invoked, it supplies  null because the exception is ignored and then a NPE occurs after client.get():

      @Override
      public List<ServiceDefinition> getServices(String name) {
          List<CatalogService> services = client.get() // null
            .catalogClient().getService(name, queryOptions).getResponse();
          .... 

      The wrapped exception should get thrown and caught with a warning in getServices or CombinedServiceDiscovery should be prepared for service discoveries that throw exceptions, log warnings and continue to ask other discoveries.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dschulten Dietrich Schulten
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: