Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7048

NPE when creating connector

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • None
    • 2.0.0
    • None
    • None

    Description

      KAFKA-6886 introduced the ConfigTransformer to transform the given configuration data. ConfigTransformer#transform(Map<String, String>) expect the passed config won't be null but DistributedHerder#putConnectorConfig call the #transform before updating the snapshot (see below). Hence, it cause the NPE. 

      // Note that we use the updated connector config despite the fact that we don't have an updated
      // snapshot yet. The existing task info should still be accurate.
      Map<String, String> map = configState.connectorConfig(connName);
      ConnectorInfo info = new ConnectorInfo(connName, config, configState.tasks(connName),
          map == null ? null : connectorTypeForClass(map.get(ConnectorConfig.CONNECTOR_CLASS_CONFIG)));
      callback.onCompletion(null, new Created<>(!exists, info));
      return null;

      We can add a null check to "configs" (see below) to resolve the NPE. It means we WON'T pass the null configs to configTransformer

      public Map<String, String> connectorConfig(String connector) {
          Map<String, String> configs = connectorConfigs.get(connector);
          if (configTransformer != null) { // add a condition "configs != null"
              configs = configTransformer.transform(connector, configs);
          }
          return configs;
      }

       

       

      Attachments

        Issue Links

          Activity

            People

              chia7712 Chia-Ping Tsai
              chia7712 Chia-Ping Tsai
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: