Skip to content

Apache Lucene open-source search software

Remove redundant field initializers (#13060)

Dmitry Cherniachenko9a88d8ad25d2
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
index 32889f37333..706b87cf80d 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilter.java
@@ -59,11 +59,11 @@ public class MinHashFilter extends TokenFilter {
private final List<List<FixedSizeTreeSet<LongPair>>> minHashSets;
- private int hashSetSize = DEFAULT_HASH_SET_SIZE;
+ private final int hashSetSize;
- private int bucketCount = DEFAULT_BUCKET_COUNT;
+ private final int bucketCount;
- private int hashCount = DEFAULT_HASH_COUNT;
+ private final int hashCount;
private boolean requiresInitialisation = true;
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilterFactory.java
index 1d2cda64e2f..dec09cb58f3 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/minhash/MinHashFilterFactory.java
@@ -32,13 +32,13 @@ public class MinHashFilterFactory extends TokenFilterFactory {
/** SPI name */
public static final String NAME = "minHash";
- private int hashCount = MinHashFilter.DEFAULT_HASH_COUNT;
+ private final int hashCount;
- private int bucketCount = MinHashFilter.DEFAULT_BUCKET_COUNT;
+ private final int bucketCount;
- private int hashSetSize = MinHashFilter.DEFAULT_HASH_SET_SIZE;
+ private final int hashSetSize;
- private boolean withRotation;
+ private final boolean withRotation;
/** Create a {@link MinHashFilterFactory}. */
public MinHashFilterFactory(Map<String, String> args) {
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterGraphFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterGraphFilterFactory.java
index 63634687e2b..570487a20b8 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterGraphFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterGraphFilterFactory.java
@@ -67,7 +67,7 @@ public class WordDelimiterGraphFilterFactory extends TokenFilterFactory
private final int flags;
byte[] typeTable = null;
private CharArraySet protectedWords = null;
- private boolean adjustOffsets = false;
+ private final boolean adjustOffsets;
/** Creates a new WordDelimiterGraphFilterFactory */
public WordDelimiterGraphFilterFactory(Map<String, String> args) {
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
index 89c67f9a832..ef188fbc42c 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
@@ -89,7 +89,7 @@ public final class DutchAnalyzer extends Analyzer {
private final CharArraySet stoptable;
/** Contains words that should be indexed but not stemmed. */
- private CharArraySet excltable = CharArraySet.EMPTY_SET;
+ private final CharArraySet excltable;
private final StemmerOverrideMap stemdict;
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternCaptureGroupFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternCaptureGroupFilterFactory.java
index da0892e16e1..fc6c78ba783 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternCaptureGroupFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternCaptureGroupFilterFactory.java
@@ -41,8 +41,8 @@ public class PatternCaptureGroupFilterFactory extends TokenFilterFactory {
/** SPI name */
public static final String NAME = "patternCaptureGroup";
- private Pattern pattern;
- private boolean preserveOriginal = true;
+ private final Pattern pattern;
+ private final boolean preserveOriginal;
public PatternCaptureGroupFilterFactory(Map<String, String> args) {
super(args);
diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
index 76105a93744..911df4eb010 100644
--- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
@@ -114,7 +114,7 @@ public class JapaneseTokenizerFactory extends TokenizerFactory implements Resour
* /箱根山-箱根/成田空港-成田/ requests "箱根" and "成田" to be in the result in NBEST output.
*/
private final String nbestExamples;
- private int nbestCost = -1;
+ private int nbestCost;
/** Creates a new JapaneseTokenizerFactory */
public JapaneseTokenizerFactory(Map<String, String> args) {
diff --git a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPTokenizer.java b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPTokenizer.java
index b9903630b25..b8a67955107 100644
--- a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPTokenizer.java
+++ b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPTokenizer.java
@@ -44,7 +44,7 @@ public final class OpenNLPTokenizer extends SegmentingTokenizerBase {
private int sentenceStart = 0;
private int sentenceIndex = -1;
- private NLPTokenizerOp tokenizerOp = null;
+ private final NLPTokenizerOp tokenizerOp;
public OpenNLPTokenizer(
AttributeFactory factory, NLPSentenceDetectorOp sentenceOp, NLPTokenizerOp tokenizerOp)
diff --git a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPChunkerOp.java b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPChunkerOp.java
index 3bd4b363957..ca67cd5b744 100644
--- a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPChunkerOp.java
+++ b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPChunkerOp.java
@@ -23,7 +23,7 @@ import opennlp.tools.chunker.ChunkerModel;
/** Supply OpenNLP Chunking tool Requires binary models from OpenNLP project on SourceForge. */
public class NLPChunkerOp {
- private ChunkerME chunker = null;
+ private final ChunkerME chunker;
public NLPChunkerOp(ChunkerModel chunkerModel) throws IOException {
chunker = new ChunkerME(chunkerModel);
diff --git a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPPOSTaggerOp.java b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPPOSTaggerOp.java
index 3301e2f446f..dee4afefc58 100644
--- a/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPPOSTaggerOp.java
+++ b/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/tools/NLPPOSTaggerOp.java
@@ -27,7 +27,7 @@ import opennlp.tools.postag.POSTaggerME;
* SourceForge.
*/
public class NLPPOSTaggerOp {
- private POSTagger tagger = null;
+ private final POSTagger tagger;
public NLPPOSTaggerOp(POSModel model) throws IOException {
tagger = new POSTaggerME(model);
diff --git a/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DaitchMokotoffSoundexFilter.java b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DaitchMokotoffSoundexFilter.java
index 5f6f0119178..5207175e5aa 100644
--- a/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DaitchMokotoffSoundexFilter.java
+++ b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DaitchMokotoffSoundexFilter.java
@@ -32,10 +32,10 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
*/
public final class DaitchMokotoffSoundexFilter extends TokenFilter {
/** true if encoded tokens should be added as synonyms */
- protected boolean inject = true;
+ private final boolean inject;
/** phonetic encoder */
- protected DaitchMokotoffSoundex encoder = new DaitchMokotoffSoundex();
+ private final DaitchMokotoffSoundex encoder = new DaitchMokotoffSoundex();
// output is a string such as ab|ac|...
private static final Pattern pattern = Pattern.compile("([^|]+)");
diff --git a/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilter.java b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilter.java
index 0212c97fac9..2084e5fc2d9 100644
--- a/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilter.java
+++ b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilter.java
@@ -32,13 +32,13 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
*/
public final class PhoneticFilter extends TokenFilter {
/** true if encoded tokens should be added as synonyms */
- protected boolean inject = true;
+ private final boolean inject;
/** phonetic encoder */
- protected Encoder encoder = null;
+ private final Encoder encoder;
/** captured state, non-null when <code>inject=true</code> and a token is buffered */
- protected State save = null;
+ private State save = null;
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posAtt = addAttribute(PositionIncrementAttribute.class);
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
index 8251e4c4b78..aef5d189747 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
@@ -73,7 +73,7 @@ public class Trie {
List<CharSequence> cmds = new ArrayList<>();
int root;
- boolean forward = false;
+ boolean forward;
/**
* Constructor for the Trie object.
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
index 92b2e057f9f..282cd72279a 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
@@ -43,7 +43,7 @@ public class TaskSequence extends PerfTask {
private boolean resetExhausted = false;
private PerfTask[] tasksArray;
private boolean anyExhaustibleTasks;
- private boolean collapsable = false; // to not collapse external sequence named in alg.
+ private final boolean collapsable; // to not collapse external sequence named in alg.
private boolean fixedTime; // true if we run for fixed time
private double runTimeSec; // how long to run for
diff --git a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TestTrecContentSource.java b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TestTrecContentSource.java
index 9a038b2bde7..71aca1e1964 100644
--- a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TestTrecContentSource.java
+++ b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TestTrecContentSource.java
@@ -36,7 +36,7 @@ public class TestTrecContentSource extends LuceneTestCase {
/** A TrecDocMaker which works on a String and not files. */
private static class StringableTrecSource extends TrecContentSource {
- private String docs = null;
+ private final String docs;
public StringableTrecSource(String docs, boolean forever) {
this.docs = docs;
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
index 03f927a552d..05c20d1ea3d 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
@@ -32,7 +32,7 @@ public final class FieldInfo {
/** Internal field number */
public final int number;
- private DocValuesType docValuesType = DocValuesType.NONE;
+ private DocValuesType docValuesType;
// True if any document indexed term vectors
private boolean storeTermVector;
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 d9ac4f37d84..c9db6d0c6f6 100644
--- a/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java
+++ b/lucene/core/src/java/org/apache/lucene/index/LiveIndexWriterConfig.java
@@ -84,7 +84,7 @@ public class LiveIndexWriterConfig {
protected volatile int perThreadHardLimitMB;
/** True if segment flushes should use compound file format */
- protected volatile boolean useCompoundFile = IndexWriterConfig.DEFAULT_USE_COMPOUND_FILE_SYSTEM;
+ protected volatile boolean useCompoundFile;
/** True if calls to {@link IndexWriter#close()} should first do a commit. */
protected boolean commitOnClose = IndexWriterConfig.DEFAULT_COMMIT_ON_CLOSE;
diff --git a/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
index f10e0fc3199..aa77b57d725 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
@@ -597,12 +597,12 @@ public abstract class MergePolicy {
* If the size of the merge segment exceeds this ratio of the total index size then it will remain
* in non-compound format
*/
- protected double noCFSRatio = DEFAULT_NO_CFS_RATIO;
+ protected double noCFSRatio;
/**
* If the size of the merged segment exceeds this value then it will not use compound file format.
*/
- protected long maxCFSSegmentSize = DEFAULT_MAX_CFS_SEGMENT_SIZE;
+ protected long maxCFSSegmentSize;
/** Creates a new merge policy instance. */
protected MergePolicy() {
diff --git a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
index 7fa2a338653..d33d3a00d37 100644
--- a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
@@ -120,7 +120,7 @@ final class WANDScorer extends Scorer {
private final int scalingFactor;
// scaled min competitive score
- private long minCompetitiveScore = 0;
+ private long minCompetitiveScore;
private final Scorer[] allScorers;
diff --git a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
index 4e9463cf82b..31199c3cd2c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
+++ b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
@@ -89,7 +89,7 @@ public class TermOrdValComparator extends FieldComparator<BytesRef> {
private boolean singleSort;
/** Whether this comparator is allowed to skip documents. */
- private boolean canSkipDocuments = true;
+ private boolean canSkipDocuments;
/** Whether the collector is done with counting hits so that we can start skipping documents. */
private boolean hitsThresholdReached = false;
diff --git a/lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java b/lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java
index 7957c7ca0d1..ccd92a74250 100644
--- a/lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java
+++ b/lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java
@@ -253,7 +253,7 @@ public class RoaringDocIdSet extends DocIdSet {
private class Iterator extends DocIdSetIterator {
int block;
- DocIdSetIterator sub = null;
+ DocIdSetIterator sub;
int doc;
Iterator() throws IOException {
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/LimitedFiniteStringsIterator.java b/lucene/core/src/java/org/apache/lucene/util/automaton/LimitedFiniteStringsIterator.java
index 853f51c8127..b4ebfe39ed0 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/LimitedFiniteStringsIterator.java
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/LimitedFiniteStringsIterator.java
@@ -31,7 +31,7 @@ import org.apache.lucene.util.IntsRef;
*/
public class LimitedFiniteStringsIterator extends FiniteStringsIterator {
/** Maximum number of finite strings to create. */
- private int limit = Integer.MAX_VALUE;
+ private final int limit;
/** Number of generated finite strings. */
private int count = 0;
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/OffsetsEnum.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/OffsetsEnum.java
index ed96d83d9a9..a18527fbb4b 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/OffsetsEnum.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/OffsetsEnum.java
@@ -123,7 +123,7 @@ public abstract class OffsetsEnum implements Comparable<OffsetsEnum>, Closeable
private final PostingsEnum postingsEnum; // with offsets
private final int freq;
- private int posCounter = -1;
+ private int posCounter;
public OfPostings(BytesRef term, int freq, PostingsEnum postingsEnum) throws IOException {
this.term = Objects.requireNonNull(term);
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/BoostQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/BoostQueryNode.java
index 42bc83cef88..a8c39a41110 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/BoostQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/BoostQueryNode.java
@@ -30,7 +30,7 @@ import org.apache.lucene.queryparser.flexible.messages.MessageImpl;
*/
public class BoostQueryNode extends QueryNodeImpl {
- private float value = 0;
+ private float value;
/**
* Constructs a boost node
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
index ed0fbdeb514..e367b70e8c9 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
@@ -84,7 +84,7 @@ public class ModifierQueryNode extends QueryNodeImpl {
}
}
- private Modifier modifier = Modifier.MOD_NONE;
+ private Modifier modifier;
/**
* Used to store the modifier value on the original query string
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/OpaqueQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/OpaqueQueryNode.java
index 52eaad22b15..d6fd81d98be 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/OpaqueQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/OpaqueQueryNode.java
@@ -25,9 +25,9 @@ import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax;
*/
public class OpaqueQueryNode extends QueryNodeImpl {
- private CharSequence schema = null;
+ private CharSequence schema;
- private CharSequence value = null;
+ private CharSequence value;
/**
* @param schema - schema identifier
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PathQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PathQueryNode.java
index 93ac8463349..620f0d2d680 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PathQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PathQueryNode.java
@@ -41,7 +41,7 @@ public class PathQueryNode extends QueryNodeImpl {
/** Term text with a beginning and end position */
public static class QueryText implements Cloneable {
- CharSequence value = null;
+ CharSequence value;
/** != null The term's begin position. */
int begin;
@@ -97,7 +97,7 @@ public class PathQueryNode extends QueryNodeImpl {
}
}
- private List<QueryText> values = null;
+ private List<QueryText> values;
/**
* @param pathElements - List of QueryText objects
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PhraseSlopQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PhraseSlopQueryNode.java
index 23d772b7b20..e3794ac6b2b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PhraseSlopQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/PhraseSlopQueryNode.java
@@ -25,7 +25,7 @@ import org.apache.lucene.search.PhraseQuery; // javadocs
/** Query node for {@link PhraseQuery}'s slop factor. */
public class PhraseSlopQueryNode extends QueryNodeImpl implements FieldableNode {
- private int value = 0;
+ private int value;
/**
* @exception QueryNodeError throw in overridden method to disallow
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ProximityQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ProximityQueryNode.java
index 5df14d555dd..e12632751c7 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ProximityQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ProximityQueryNode.java
@@ -57,9 +57,9 @@ public class ProximityQueryNode extends BooleanQueryNode {
/** utility class containing the distance condition and number */
public static class ProximityType {
- int pDistance = 0;
+ int pDistance;
- Type pType = null;
+ Type pType;
public ProximityType(Type type) {
this(type, 0);
@@ -71,10 +71,10 @@ public class ProximityQueryNode extends BooleanQueryNode {
}
}
- private Type proximityType = Type.SENTENCE;
+ private Type proximityType;
private int distance = -1;
- private boolean inorder = false;
- private CharSequence field = null;
+ private final boolean inorder;
+ private CharSequence field;
/**
* @param clauses - QueryNode children
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/SlopQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/SlopQueryNode.java
index 0ad088dba7f..2af07255a1b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/SlopQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/SlopQueryNode.java
@@ -32,7 +32,7 @@ import org.apache.lucene.queryparser.flexible.messages.MessageImpl;
*/
public class SlopQueryNode extends QueryNodeImpl implements FieldableNode {
- private int value = 0;
+ private int value;
/**
* @param query - QueryNode Tree with the phrase
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldBoostMapFCListener.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldBoostMapFCListener.java
index 3f65b3409b1..465dc8b1ca0 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldBoostMapFCListener.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldBoostMapFCListener.java
@@ -34,7 +34,7 @@ import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfi
*/
public class FieldBoostMapFCListener implements FieldConfigListener {
- private QueryConfigHandler config = null;
+ private final QueryConfigHandler config;
public FieldBoostMapFCListener(QueryConfigHandler config) {
this.config = config;
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldDateResolutionFCListener.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldDateResolutionFCListener.java
index 2987a470093..1ff7d54893b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldDateResolutionFCListener.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/FieldDateResolutionFCListener.java
@@ -36,7 +36,7 @@ import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfi
*/
public class FieldDateResolutionFCListener implements FieldConfigListener {
- private QueryConfigHandler config = null;
+ private final QueryConfigHandler config;
public FieldDateResolutionFCListener(QueryConfigHandler config) {
this.config = config;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/index/DocHelper.java b/lucene/test-framework/src/java/org/apache/lucene/tests/index/DocHelper.java
index f8fea3c8c06..b51842c8a40 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/index/DocHelper.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/index/DocHelper.java
@@ -175,7 +175,7 @@ public class DocHelper {
public static Field textUtfField2 =
new Field(TEXT_FIELD_UTF2_KEY, FIELD_UTF2_TEXT, TEXT_TYPE_STORED_WITH_TVS);
- public static Map<String, Object> nameValues = null;
+ public static Map<String, Object> nameValues;
// ordered list of all the fields...
// could use LinkedHashMap for this purpose if Java1.4 is OK