Skip to content

Commit

Permalink
fix: filter null entries before creating KafkaConfigStore (#3147)
Browse files Browse the repository at this point in the history
  • Loading branch information
agavra committed Jul 30, 2019
1 parent 377e961 commit 2852af1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;
Expand Down Expand Up @@ -116,7 +117,11 @@ public static class KsqlProperties {
KsqlProperties(
@JsonProperty("ksqlProperties") final Map<String, String> ksqlProperties) {
this.ksqlProperties = ksqlProperties == null
? Collections.emptyMap() : ImmutableMap.copyOf(ksqlProperties);
? Collections.emptyMap()
: ksqlProperties.entrySet()
.stream()
.filter(kv -> kv.getValue() != null)
.collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue));
}

public Map<String, String> getKsqlProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public class KafkaConfigStoreTest {
ImmutableMap.of(KsqlConfig.KSQL_PERSISTENT_QUERY_NAME_PREFIX_CONFIG, "bad"));

private final KsqlProperties properties = new KsqlProperties(
filterNullValues(currentConfig.getAllConfigPropsWithSecretsObfuscated())
currentConfig.getAllConfigPropsWithSecretsObfuscated()
);
private final KsqlProperties savedProperties = new KsqlProperties(
filterNullValues(savedConfig.getAllConfigPropsWithSecretsObfuscated())
savedConfig.getAllConfigPropsWithSecretsObfuscated()
);
private final KsqlProperties badProperties = new KsqlProperties(
filterNullValues(badConfig.getAllConfigPropsWithSecretsObfuscated())
badConfig.getAllConfigPropsWithSecretsObfuscated()
);

private final TopicPartition topicPartition = new TopicPartition(TOPIC_NAME, 0);
Expand Down Expand Up @@ -107,7 +107,6 @@ public class KafkaConfigStoreTest {
private InOrder inOrder;

@Before
@SuppressWarnings("unchecked")
public void setUp() {
when(producerSupplier.get()).thenReturn(producer);
when(consumerSupplier.get()).thenReturn(consumerBefore).thenReturn(consumerAfter);
Expand Down

0 comments on commit 2852af1

Please sign in to comment.