Skip to content

Commit 6415979

Browse files
Do not attempt to add null content to Lucene index (#1466)
Co-authored-by: German Osin <[email protected]>
1 parent 13f545b commit 6415979

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/src/main/java/io/kafbat/ui/service/index/LuceneTopicsIndex.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.locks.ReentrantReadWriteLock;
1616
import java.util.function.Function;
1717
import java.util.stream.Collectors;
18+
import lombok.extern.slf4j.Slf4j;
1819
import org.apache.lucene.analysis.Analyzer;
1920
import org.apache.lucene.document.Document;
2021
import org.apache.lucene.document.Field;
@@ -40,6 +41,7 @@
4041
import org.apache.lucene.store.ByteBuffersDirectory;
4142
import org.apache.lucene.store.Directory;
4243

44+
@Slf4j
4345
public class LuceneTopicsIndex implements TopicsIndex {
4446
public static final String FIELD_NAME_RAW = "name_raw";
4547

@@ -74,9 +76,15 @@ private Directory build(List<InternalTopic> topics) {
7476
doc.add(new LongPoint(FIELD_SIZE, topic.getSegmentSize()));
7577
if (topic.getTopicConfigs() != null && !topic.getTopicConfigs().isEmpty()) {
7678
for (InternalTopicConfig topicConfig : topic.getTopicConfigs()) {
77-
if (topicConfig.getName() != null || topicConfig.getValue() != null) {
79+
final String topicConfigValue = topicConfig.getValue();
80+
if (topicConfigValue != null) {
7881
doc.add(new StringField(FIELD_CONFIG_PREFIX + "_" + topicConfig.getName(), topicConfig.getValue(),
7982
Field.Store.NO));
83+
} else {
84+
log.info(
85+
"Topic configuration item '{}' on internal topic '{}' has an unexpected value of null"
86+
+ "; skipping processing", topicConfig.getName(), topic.getName()
87+
);
8088
}
8189
}
8290
}

0 commit comments

Comments
 (0)