You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/09/18 23:37:52 UTC

[GitHub] [kafka] abbccdda commented on a change in pull request #11333: KAFKA-13306: Null connector config value passes validation, but fails creation

abbccdda commented on a change in pull request #11333:
URL: https://github.com/apache/kafka/pull/11333#discussion_r711655376



##########
File path: connect/api/src/main/java/org/apache/kafka/connect/connector/Connector.java
##########
@@ -150,4 +152,15 @@ public Config validate(Map<String, String> connectorConfigs) {
      * @return The ConfigDef for this connector; may not be null.
      */
     public abstract ConfigDef config();
+
+    private void validateConfigDoesNotContainNull(Map<String, String> connectorConfigs) {
+        final String keysWithNullValue = connectorConfigs.entrySet().stream()
+                .filter(entry -> entry.getValue() == null)
+                .map(Map.Entry::getKey)
+                .collect(Collectors.joining(", "));
+
+        if (!keysWithNullValue.isEmpty()) {
+            throw new ConnectException(String.format("Null value found in config for key(s) %s", keysWithNullValue));

Review comment:
       Should this just be IllegalArgumentException?

##########
File path: connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java
##########
@@ -289,6 +290,23 @@ public void testBuildRestartPlanForUnknownConnector() {
         assertFalse(mayBeRestartPlan.isPresent());
     }
 
+    @Test
+    public void testConfigValidationNullConfig() {

Review comment:
       Could you also add a test case with multiple null values as well?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org