Browse Source

MINOR: Change the order that Connect calls `config()` and `validate()` to avoid validating if the required ConfigDef is null (#8810)

Author: Randall Hauch <rhauch@gmail.com>
Reviewer: Konstantine Karantasis <konstantine@confluent.io>
pull/8270/head
Randall Hauch 5 years ago committed by GitHub
parent
commit
8f552fd6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java

24
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java

@ -341,22 +341,22 @@ public abstract class AbstractHerder implements Herder, TaskStatus.Listener, Con @@ -341,22 +341,22 @@ public abstract class AbstractHerder implements Herder, TaskStatus.Listener, Con
Set<String> allGroups = new LinkedHashSet<>(enrichedConfigDef.groups());
// do custom connector-specific validation
Config config = connector.validate(connectorProps);
if (null == config) {
ConfigDef configDef = connector.config();
if (null == configDef) {
throw new BadRequestException(
String.format(
"%s.validate() must return a Config that is not null.",
connector.getClass().getName()
)
String.format(
"%s.config() must return a ConfigDef that is not null.",
connector.getClass().getName()
)
);
}
ConfigDef configDef = connector.config();
if (null == configDef) {
Config config = connector.validate(connectorProps);
if (null == config) {
throw new BadRequestException(
String.format(
"%s.config() must return a ConfigDef that is not null.",
connector.getClass().getName()
)
String.format(
"%s.validate() must return a Config that is not null.",
connector.getClass().getName()
)
);
}
configKeys.putAll(configDef.configKeys());

Loading…
Cancel
Save