diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java index c773326f29c..09b3b1fcf0c 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java @@ -288,6 +288,9 @@ public final class IndexWriterConfig extends LiveIndexWriterConfig implements Cl * Only takes effect when IndexWriter is first created. */ public IndexWriterConfig setCodec(Codec codec) { + if (codec == null) { + throw new NullPointerException(); + } this.codec = codec; return this; } diff --git a/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java b/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java index f7f63949f47..448715acc35 100755 --- a/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java +++ b/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java @@ -116,6 +116,9 @@ public class LiveIndexWriterConfig { writeLockTimeout = IndexWriterConfig.WRITE_LOCK_TIMEOUT; indexingChain = DocumentsWriterPerThread.defaultIndexingChain; codec = Codec.getDefault(); + if (codec == null) { + throw new NullPointerException(); + } infoStream = InfoStream.getDefault(); mergePolicy = new TieredMergePolicy(); flushPolicy = new FlushByRamOrCountsPolicy(); diff --git a/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java b/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java index 254cea37e38..42fa2e951fa 100644 --- a/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java +++ b/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldDocValuesFormat.java @@ -55,8 +55,8 @@ public class TestPerFieldDocValuesFormat extends BaseDocValuesFormatTestCase { @Override public void setUp() throws Exception { - super.setUp(); codec = new RandomCodec(new Random(random().nextLong()), Collections.emptySet()); + super.setUp(); } @Override