Skip to content

Commit e90b027

Browse files
authored
Merge pull request #63 from rozza/k203
Fixed sink NPE issue when using with confluent connect 6.1.0
2 parents 6330cb9 + da96f33 commit e90b027

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
### Bug Fixes
1515
- [KAFKA-195](https://jira.mongodb.org/browse/KAFKA-195) Fixed topics.regex sink validation issue for synthetic config property
16-
16+
- [KAFKA-203](https://jira.mongodb.org/browse/KAFKA-203) Fixed sink NPE issue when using with confluent connect 6.1.0
1717

1818
## 1.4.0
1919

src/main/java/com/mongodb/kafka/connect/sink/MongoSinkConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class MongoSinkConfig extends AbstractConfig {
8888

8989
static final String PROVIDER_CONFIG = "provider";
9090

91-
static final List<String> IGNORED_CONFIGS = singletonList(TOPIC_OVERRIDE_CONFIG);
91+
static final List<String> INVISIBLE_CONFIGS = singletonList(TOPIC_OVERRIDE_CONFIG);
9292

9393
private Map<String, String> originals;
9494
private final Optional<List<String>> topics;
@@ -195,7 +195,12 @@ private static ConfigDef createConfigDef() {
195195
@SuppressWarnings("unchecked")
196196
public Map<String, ConfigValue> validateAll(final Map<String, String> props) {
197197
Map<String, ConfigValue> results = super.validateAll(props);
198-
IGNORED_CONFIGS.forEach(results::remove);
198+
INVISIBLE_CONFIGS.forEach(
199+
c -> {
200+
if (results.containsKey(c)) {
201+
results.get(c).visible(false);
202+
}
203+
});
199204
// Don't validate child configs if the top level configs are broken
200205
if (results.values().stream().anyMatch((c) -> !c.errorMessages().isEmpty())) {
201206
return results;

src/main/java/com/mongodb/kafka/connect/sink/MongoSinkTopicConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public String value() {
328328

329329
public static final String ID_FIELD = "_id";
330330

331-
static final List<String> IGNORED_CONFIGS = singletonList(TOPIC_CONFIG);
331+
static final List<String> SYNTHETIC_CONFIGS = singletonList(TOPIC_CONFIG);
332332

333333
private static final List<Consumer<MongoSinkTopicConfig>> INITIALIZERS =
334334
asList(
@@ -512,7 +512,7 @@ static Map<String, ConfigValue> validateAll(final String topic, final Map<String
512512
.forEach(
513513
(k, v) -> {
514514
String name = topicOverrides.contains(prefix + k) ? prefix + k : k;
515-
if (props.containsKey(name) && !IGNORED_CONFIGS.contains(name)) {
515+
if (props.containsKey(name) && !SYNTHETIC_CONFIGS.contains(name)) {
516516
results.put(
517517
name,
518518
new ConfigValue(name, v.value(), v.recommendedValues(), v.errorMessages()));
@@ -567,7 +567,7 @@ static Map<String, ConfigValue> validateRegexAll(final Map<String, String> props
567567
.validateAll(sinkTopicOriginals)
568568
.forEach(
569569
(k, v) -> {
570-
if (!IGNORED_CONFIGS.contains(k)) {
570+
if (!SYNTHETIC_CONFIGS.contains(k)) {
571571
results.put(
572572
k, new ConfigValue(k, v.value(), v.recommendedValues(), v.errorMessages()));
573573
}

src/test/java/com/mongodb/kafka/connect/sink/MongoSinkConfigTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ void testValidation() {
172172

173173
Set<String> expectedKeys = new HashSet<>(MongoSinkConfig.CONFIG.configKeys().keySet());
174174
expectedKeys.addAll(MongoSinkTopicConfig.CONFIG.configKeys().keySet());
175-
// Remove ignored configs
176-
expectedKeys.removeAll(MongoSinkConfig.IGNORED_CONFIGS);
177-
expectedKeys.removeAll(MongoSinkTopicConfig.IGNORED_CONFIGS);
175+
// Remove Synthetic configs
176+
expectedKeys.removeAll(MongoSinkTopicConfig.SYNTHETIC_CONFIGS);
178177

179178
// Added declared overrides
180179
expectedKeys.addAll(configMap.keySet());
@@ -196,9 +195,7 @@ void testValidationRegex() {
196195

197196
Set<String> expectedKeys = new HashSet<>(MongoSinkConfig.CONFIG.configKeys().keySet());
198197
expectedKeys.addAll(MongoSinkTopicConfig.CONFIG.configKeys().keySet());
199-
// Remove ignored configs
200-
expectedKeys.removeAll(MongoSinkConfig.IGNORED_CONFIGS);
201-
expectedKeys.removeAll(MongoSinkTopicConfig.IGNORED_CONFIGS);
198+
expectedKeys.removeAll(MongoSinkTopicConfig.SYNTHETIC_CONFIGS);
202199

203200
// Added declared overrides
204201
expectedKeys.addAll(configMap.keySet());

0 commit comments

Comments
 (0)