Skip to content

Commit

Permalink
fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Nov 6, 2024
1 parent b99f66f commit 497e0e0
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2709,8 +2709,7 @@ private IndexWriterConfig getIndexWriterConfig() {
// always configure soft-deletes field so an engine with soft-deletes disabled can open a Lucene index with soft-deletes.
iwc.setSoftDeletesField(Lucene.SOFT_DELETES_FIELD);
mergePolicy = new RecoverySourcePruneMergePolicy(
engineConfig.getMapperService().mappingLookup().isSourceSynthetic()
&& engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled() ? null : SourceFieldMapper.RECOVERY_SOURCE_NAME,
useSyntheticSourceForRecovery() ? null : SourceFieldMapper.RECOVERY_SOURCE_NAME,
SourceFieldMapper.RECOVERY_SOURCE_SIZE_NAME,
engineConfig.getIndexSettings().getMode() == IndexMode.TIME_SERIES,
softDeletesPolicy::getRetentionQuery,
Expand Down Expand Up @@ -2755,6 +2754,13 @@ private IndexWriterConfig getIndexWriterConfig() {
return iwc;
}

private boolean useSyntheticSourceForRecovery() {
return engineConfig.getMapperService() != null
&& engineConfig.getMapperService().mappingLookup().isSourceSynthetic()
&& engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled();

}

/** A listener that warms the segments if needed when acquiring a new reader */
static final class RefreshWarmerListener implements BiConsumer<ElasticsearchDirectoryReader, ElasticsearchDirectoryReader> {
private final Warmer warmer;
Expand Down Expand Up @@ -3156,8 +3162,7 @@ public Translog.Snapshot newChangesSnapshot(
Searcher searcher = acquireSearcher(source, SearcherScope.INTERNAL);
try {
final Translog.Snapshot snapshot;
if (engineConfig.getMapperService().mappingLookup().isSourceSynthetic()
&& engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()) {
if (useSyntheticSourceForRecovery()) {
snapshot = new LuceneSyntheticSourceChangesSnapshot(
engineConfig.getMapperService().mappingLookup(),
searcher,
Expand Down

0 comments on commit 497e0e0

Please sign in to comment.