Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-5159

TestContainers method DebeziumContainer#getConnectorTaskState can raise a NullPointerException

    XMLWordPrintable

Details

    Description

      When a test calls DebeziumContainer#getConnectorTaskState, it is possible that the returned tasks array is empty as the Kafka Connect container may not have yet started the tasks. When this happens, a NullPointerException is raised.

      I propose a small check in the method such as:

      final JsonNode tasksNode = parsedObject.get("tasks").get(taskNumber);
      if (tasksNode == null) {
        return null;
      }
      return Connector.State.valueOf(tasksNode.get("state").asText());
      

      This way if the specific task has not yet started, we avoid the NPE by returning null and allowing the caller's Awaility method to re-check periodically without failure.

      Attachments

        Activity

          People

            ccranfor@redhat.com Chris Cranford
            ccranfor@redhat.com Chris Cranford
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: