Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@ protected final boolean maybeAddConfigErrors(
messages.append("Connector configuration is invalid and contains the following ")
.append(errors).append(" error(s):");
for (ConfigInfo configInfo : configInfos.configs()) {
if (configInfo == null || configInfo.configValue() == null) {
continue;
}
for (String msg : configInfo.configValue().errors()) {
messages.append('\n').append(msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,41 @@ public void testGenerateResultWithConfigValuesWithNoConfigKeysAndWithSomeErrors(
assertInfoValue(infos, "config.extra2", "value.extra2", "error extra2");
}

@Test
public void testMaybeAddConfigErrorsWithNullConfigInfoAndNullConfigValue() throws Exception {
AbstractHerder herder = testHerder();
Map<String, ConfigDef.ConfigKey> keys = new HashMap<>();
addConfigKey(keys, "config.a1", null);
addConfigKey(keys, "config.b1", "group B");

List<ConfigValue> values = new ArrayList<>();
addValue(values, "config.b1", "value.b1", "error b1");

ConfigInfos infos = AbstractHerder.generateResult(
"com.acme.connector.MyConnector", keys, values, List.of("group B"));
infos.configs().add(null);

FutureCallback<Herder.Created<ConnectorInfo>> callback = new FutureCallback<>();
assertTrue(herder.maybeAddConfigErrors(infos, callback));
ExecutionException e = assertThrows(ExecutionException.class, callback::get);
assertTrue(e.getCause() instanceof BadRequestException);
}

@Test
public void testMaybeAddConfigErrorsWithNullConfigValueAndNoErrors() {
AbstractHerder herder = testHerder();
Map<String, ConfigDef.ConfigKey> keys = new HashMap<>();
addConfigKey(keys, "config.a1", null);
addConfigKey(keys, "config.b1", "group B");

List<ConfigValue> values = new ArrayList<>();
addValue(values, "config.b1", "value.b1");

ConfigInfos infos = AbstractHerder.generateResult(
"com.acme.connector.MyConnector", keys, values, List.of("group B"));
assertFalse(herder.maybeAddConfigErrors(infos, new FutureCallback<>()));
}

@Test
public void testSinkConnectorPluginConfig() throws ClassNotFoundException {
testConnectorPluginConfig(
Expand Down