You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2021/03/27 15:43:58 UTC

[lucene] branch main updated: LUCENE-9878: enable redundantNullCheck in ecjLint (#44)

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 3596e05  LUCENE-9878: enable redundantNullCheck in ecjLint (#44)
3596e05 is described below

commit 3596e05e5cb7c0641f82300e6ed4d091eab0fdd0
Author: Robert Muir <rm...@apache.org>
AuthorDate: Sat Mar 27 11:43:47 2021 -0400

    LUCENE-9878: enable redundantNullCheck in ecjLint (#44)
    
    Detects common cases of unreachable/dead code.
    
    For generated javacc code, the check is disabled via
    SuppressWarnings("unused") because javacc generates strange/bad code such as:
    
      if ("" == null)
    
    For TestStressNRTReplication's startNode() method, the check is also
    disabled because analysis folds the "test evilness controls" which are
    static final constants. This itself is a WTF, shouldn't we instead
    randomize these evil things in our tests rather than hardcoding them to
    specific values?
---
 gradle/generation/javacc.gradle                    |  6 ++--
 gradle/validation/ecj-lint/ecj.javadocs.prefs      |  2 +-
 .../Lucene90CompressingStoredFieldsReader.java     |  6 ++--
 .../Lucene90CompressingTermVectorsReader.java      |  6 ++--
 .../java/org/apache/lucene/geo/Tessellator.java    | 11 +++---
 .../java/org/apache/lucene/index/CheckIndex.java   |  9 -----
 .../java/org/apache/lucene/index/IndexWriter.java  | 16 ++++-----
 .../java/org/apache/lucene/index/MultiFields.java  |  6 +---
 .../java/org/apache/lucene/search/PrefixQuery.java |  3 --
 .../apache/lucene/store/SleepingLockWrapper.java   |  5 +--
 .../lucene/index/TestDemoParallelLeafReader.java   |  1 -
 .../org/apache/lucene/index/TestIndexSorting.java  |  2 +-
 .../org/apache/lucene/search/TestPointQueries.java | 12 +++----
 .../apache/lucene/search/TestShardSearching.java   |  9 ++---
 .../apache/lucene/search/grouping/SearchGroup.java |  4 +--
 .../apache/lucene/search/join/TestBlockJoin.java   | 32 ++++++++---------
 .../lucene/queryparser/classic/QueryParser.java    |  2 +-
 .../standard/parser/StandardSyntaxParser.java      |  2 +-
 .../processors/MultiFieldQueryNodeProcessor.java   |  2 +-
 .../queryparser/surround/parser/QueryParser.java   |  2 +-
 .../queryparser/surround/query/SrndTruncQuery.java |  2 +-
 .../replicator/nrt/TestStressNRTReplication.java   |  1 +
 .../search/LatLonPointPrototypeQueries.java        |  8 ++---
 .../lucene/spatial3d/geom/GeoDegeneratePath.java   |  3 --
 .../lucene/spatial3d/geom/GeoStandardPath.java     |  3 --
 .../apache/lucene/spatial3d/geom/SidedPlane.java   | 24 ++++++-------
 .../lucene/index/BaseDocValuesFormatTestCase.java  |  2 +-
 .../lucene/store/BaseLockFactoryTestCase.java      | 40 ++++++++++------------
 28 files changed, 84 insertions(+), 137 deletions(-)

diff --git a/gradle/generation/javacc.gradle b/gradle/generation/javacc.gradle
index 4b1e781..1294ef2 100644
--- a/gradle/generation/javacc.gradle
+++ b/gradle/generation/javacc.gradle
@@ -131,7 +131,7 @@ configure(project(":lucene:queryparser")) {
               "static final private LookaheadSuccess jj_ls =")
           text = text.replace(
               "public class QueryParser ",
-              '@SuppressWarnings("unused") public class QueryParser ')
+              '@SuppressWarnings({"unused","null"}) public class QueryParser ')
           text = text.replace(
               "final public Query TopLevelQuery(",
               "@Override final public Query TopLevelQuery(")
@@ -162,7 +162,7 @@ configure(project(":lucene:queryparser")) {
               "new java.util.ArrayList<>")
           text = text.replace(
               "public class QueryParser ",
-              '@SuppressWarnings("unused") public class QueryParser ')
+              '@SuppressWarnings({"unused","null"}) public class QueryParser ')
           return text
         })
       }
@@ -241,7 +241,7 @@ configure(project(":lucene:queryparser")) {
               "Collections.singletonList")
           text = text.replace(
               "public class StandardSyntaxParser ",
-              '@SuppressWarnings("unused") public class StandardSyntaxParser ')
+              '@SuppressWarnings({"unused","null"}) public class StandardSyntaxParser ')
           return text
         })
       }
diff --git a/gradle/validation/ecj-lint/ecj.javadocs.prefs b/gradle/validation/ecj-lint/ecj.javadocs.prefs
index 34fb98b..5bdfb3f 100644
--- a/gradle/validation/ecj-lint/ecj.javadocs.prefs
+++ b/gradle/validation/ecj-lint/ecj.javadocs.prefs
@@ -89,7 +89,7 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
 # TODO: generics-related warning that is normally enabled by default
 org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
 org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
 org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
 org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java
index fb71596..cdb7d8e 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java
@@ -180,10 +180,8 @@ public final class Lucene90CompressingStoredFieldsReader extends StoredFieldsRea
       numDirtyChunks = metaIn.readVLong();
       numDirtyDocs = metaIn.readVLong();
 
-      if (metaIn != null) {
-        CodecUtil.checkFooter(metaIn, null);
-        metaIn.close();
-      }
+      CodecUtil.checkFooter(metaIn, null);
+      metaIn.close();
 
       success = true;
     } catch (Throwable t) {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsReader.java
index 7aca22b..308c4eb 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsReader.java
@@ -174,10 +174,8 @@ public final class Lucene90CompressingTermVectorsReader extends TermVectorsReade
       this.reader =
           new BlockPackedReaderIterator(vectorsStream, packedIntsVersion, PACKED_BLOCK_SIZE, 0);
 
-      if (metaIn != null) {
-        CodecUtil.checkFooter(metaIn, null);
-        metaIn.close();
-      }
+      CodecUtil.checkFooter(metaIn, null);
+      metaIn.close();
 
       success = true;
     } catch (Throwable t) {
diff --git a/lucene/core/src/java/org/apache/lucene/geo/Tessellator.java b/lucene/core/src/java/org/apache/lucene/geo/Tessellator.java
index 5289169..da08467 100644
--- a/lucene/core/src/java/org/apache/lucene/geo/Tessellator.java
+++ b/lucene/core/src/java/org/apache/lucene/geo/Tessellator.java
@@ -265,13 +265,10 @@ public final class Tessellator {
       if (list == list.next) {
         throw new IllegalArgumentException("Points are all coplanar in hole: " + holes[i]);
       }
-      // Determine if the resulting hole polygon was successful.
-      if (list != null) {
-        // Add the leftmost vertex of the hole.
-        Node leftMost = fetchLeftmost(list);
-        holeList.add(leftMost);
-        holeListPolygons.put(leftMost, holes[i]);
-      }
+      // Add the leftmost vertex of the hole.
+      Node leftMost = fetchLeftmost(list);
+      holeList.add(leftMost);
+      holeListPolygons.put(leftMost, holes[i]);
       nodeIndex += holes[i].numPoints();
     }
     return eliminateHoles(holeList, holeListPolygons, outerNode);
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index 8ce1cfe..e9c4514 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -638,7 +638,6 @@ public final class CheckIndex implements Closeable {
       int toLoseDocCount = info.info.maxDoc();
 
       SegmentReader reader = null;
-      Sort previousIndexSort = null;
 
       try {
         msg(infoStream, "    version=" + (version == null ? "3.0" : version));
@@ -652,14 +651,6 @@ public final class CheckIndex implements Closeable {
         Sort indexSort = info.info.getIndexSort();
         if (indexSort != null) {
           msg(infoStream, "    sort=" + indexSort);
-          if (previousIndexSort != null) {
-            if (previousIndexSort.equals(indexSort) == false) {
-              throw new RuntimeException(
-                  "index sort changed from " + previousIndexSort + " to " + indexSort);
-            }
-          } else {
-            previousIndexSort = indexSort;
-          }
         }
         segInfoStat.numFiles = info.files().size();
         segInfoStat.sizeMB = info.sizeInBytes() / (1024. * 1024.);
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 9c3351c..fe40fbe 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -4241,17 +4241,13 @@ public class IndexWriter
     }
 
     if (infoStream.isEnabled("IW")) {
-      if (mergedDeletesAndUpdates == null) {
-        infoStream.message("IW", "no new deletes or field updates since merge started");
-      } else {
-        String msg = mergedDeletesAndUpdates.getDelCount() - numDeletesBefore + " new deletes";
-        if (anyDVUpdates) {
-          msg += " and " + mergedDeletesAndUpdates.getNumDVUpdates() + " new field updates";
-          msg += " (" + mergedDeletesAndUpdates.ramBytesUsed.get() + ") bytes";
-        }
-        msg += " since merge started";
-        infoStream.message("IW", msg);
+      String msg = mergedDeletesAndUpdates.getDelCount() - numDeletesBefore + " new deletes";
+      if (anyDVUpdates) {
+        msg += " and " + mergedDeletesAndUpdates.getNumDVUpdates() + " new field updates";
+        msg += " (" + mergedDeletesAndUpdates.ramBytesUsed.get() + ") bytes";
       }
+      msg += " since merge started";
+      infoStream.message("IW", msg);
     }
 
     merge.info.setBufferedDeletesGen(minGen);
diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
index 898cbd2..46de8ad 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
@@ -75,11 +75,7 @@ public final class MultiFields extends Fields {
         slices2.add(subSlices[i]);
       }
     }
-    if (subs2.size() == 0) {
-      result = null;
-      // don't cache this case with an unbounded cache, since the number of fields that don't exist
-      // is unbounded.
-    } else {
+    if (subs2.size() != 0) {
       result =
           new MultiTerms(
               subs2.toArray(Terms.EMPTY_ARRAY), slices2.toArray(ReaderSlice.EMPTY_ARRAY));
diff --git a/lucene/core/src/java/org/apache/lucene/search/PrefixQuery.java b/lucene/core/src/java/org/apache/lucene/search/PrefixQuery.java
index c4092ee..4cd6023 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PrefixQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PrefixQuery.java
@@ -33,9 +33,6 @@ public class PrefixQuery extends AutomatonQuery {
     // It's OK to pass unlimited maxDeterminizedStates: the automaton is born small and
     // determinized:
     super(prefix, toAutomaton(prefix.bytes()), Integer.MAX_VALUE, true);
-    if (prefix == null) {
-      throw new NullPointerException("prefix must not be null");
-    }
   }
 
   /** Build an automaton accepting all terms with the specified prefix. */
diff --git a/lucene/core/src/java/org/apache/lucene/store/SleepingLockWrapper.java b/lucene/core/src/java/org/apache/lucene/store/SleepingLockWrapper.java
index 786b452..7bb7ee3 100644
--- a/lucene/core/src/java/org/apache/lucene/store/SleepingLockWrapper.java
+++ b/lucene/core/src/java/org/apache/lucene/store/SleepingLockWrapper.java
@@ -95,10 +95,7 @@ public final class SleepingLockWrapper extends FilterDirectory {
     } while (sleepCount++ < maxSleepCount || lockWaitTimeout == LOCK_OBTAIN_WAIT_FOREVER);
 
     // we failed to obtain the lock in the required time
-    String reason = "Lock obtain timed out: " + this.toString();
-    if (failureReason != null) {
-      reason += ": " + failureReason;
-    }
+    String reason = "Lock obtain timed out: " + this.toString() + ": " + failureReason;
     throw new LockObtainFailedException(reason, failureReason);
   }
 
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
index 37b5388..1ff5a84 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
@@ -529,7 +529,6 @@ public class TestDemoParallelLeafReader extends LuceneTestCase {
               // closing (which makes MDW.close's
               // checkIndex angry):
               closedSegments.add(segIDGen);
-              parReader = null;
             }
             parReader = parLeafReader;
 
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
index 4bce7ce..0aba691 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
@@ -2142,7 +2142,7 @@ public class TestIndexSorting extends LuceneTestCase {
 
     Directory dir2 = newDirectory();
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
-    if (indexSort != null && random().nextBoolean()) {
+    if (random().nextBoolean()) {
       // test congruent index sort
       iwc.setIndexSort(new Sort(new SortField("foo", SortField.Type.LONG)));
     } else {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
index efe218a..894635c 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
@@ -552,14 +552,10 @@ public class TestPointQueries extends LuceneTestCase {
                           + " TO "
                           + upper);
                   byte[] tmp = new byte[8];
-                  if (lower != null) {
-                    NumericUtils.longToSortableBytes(lower, tmp, 0);
-                    System.out.println("  lower bytes=" + Arrays.toString(tmp));
-                  }
-                  if (upper != null) {
-                    NumericUtils.longToSortableBytes(upper, tmp, 0);
-                    System.out.println("  upper bytes=" + Arrays.toString(tmp));
-                  }
+                  NumericUtils.longToSortableBytes(lower, tmp, 0);
+                  System.out.println("  lower bytes=" + Arrays.toString(tmp));
+                  NumericUtils.longToSortableBytes(upper, tmp, 0);
+                  System.out.println("  upper bytes=" + Arrays.toString(tmp));
                 }
 
                 if (random().nextBoolean()) {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestShardSearching.java b/lucene/core/src/test/org/apache/lucene/search/TestShardSearching.java
index 8f990e2..825ba82 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestShardSearching.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestShardSearching.java
@@ -378,14 +378,9 @@ public class TestShardSearching extends ShardSearchingTestBase {
       }
     }
 
-    int numHitsPaged;
+    int numHitsPaged = hits.scoreDocs.length;
     if (state != null && state.searchAfterLocal != null) {
-      numHitsPaged = hits.scoreDocs.length;
-      if (state != null) {
-        numHitsPaged += state.numHitsPaged;
-      }
-    } else {
-      numHitsPaged = hits.scoreDocs.length;
+      numHitsPaged += state.numHitsPaged;
     }
 
     final boolean moreHits;
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
index f859e47..d322135 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
@@ -143,9 +143,9 @@ public class SearchGroup<T> {
       if (_other instanceof MergedGroup) {
         MergedGroup<?> other = (MergedGroup<?>) _other;
         if (groupValue == null) {
-          return other == null;
+          return other.groupValue == null;
         } else {
-          return groupValue.equals(other);
+          return groupValue.equals(other.groupValue);
         }
       } else {
         return false;
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
index 31702d7..82886d3 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
@@ -855,26 +855,24 @@ public class TestBlockJoin extends LuceneTestCase {
       if (VERBOSE) {
         System.out.println(
             "\nTEST: block join index gets "
-                + (joinResults == null ? 0 : joinResults.size())
+                + joinResults.size()
                 + " groups; hitsPerGroup="
                 + hitsPerGroup);
-        if (joinResults != null) {
-          for (Map.Entry<Integer, TopDocs> entry : joinResults.entrySet()) {
+        for (Map.Entry<Integer, TopDocs> entry : joinResults.entrySet()) {
+          System.out.println(
+              "  group parentID=" + entry.getKey() + " (docID=" + entry.getKey() + ")");
+          for (ScoreDoc childHit : entry.getValue().scoreDocs) {
+            final Document doc = joinS.doc(childHit.doc);
+            //              System.out.println("    score=" + childHit.score + " childID=" +
+            // doc.get("childID") + " (docID=" + childHit.doc + ")");
             System.out.println(
-                "  group parentID=" + entry.getKey() + " (docID=" + entry.getKey() + ")");
-            for (ScoreDoc childHit : entry.getValue().scoreDocs) {
-              final Document doc = joinS.doc(childHit.doc);
-              //              System.out.println("    score=" + childHit.score + " childID=" +
-              // doc.get("childID") + " (docID=" + childHit.doc + ")");
-              System.out.println(
-                  "    childID="
-                      + doc.get("childID")
-                      + " child0="
-                      + doc.get("child0")
-                      + " (docID="
-                      + childHit.doc
-                      + ")");
-            }
+                "    childID="
+                    + doc.get("childID")
+                    + " child0="
+                    + doc.get("child0")
+                    + " (docID="
+                    + childHit.doc
+                    + ")");
           }
         }
       }
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
index 010f424..e268add 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
@@ -81,7 +81,7 @@ import org.apache.lucene.queryparser.charstream.FastCharStream;
  * the same syntax as this class, but is more modular,
  * enabling substantial customization to how a query is created.
  */
-@SuppressWarnings("unused") public class QueryParser extends QueryParserBase implements QueryParserConstants {
+@SuppressWarnings({"unused","null"}) public class QueryParser extends QueryParserBase implements QueryParserConstants {
   /** The default operator for parsing queries.
    * Use {@link QueryParserBase#setDefaultOperator} to change it.
    */
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
index 8c4011f..8824040 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
@@ -50,7 +50,7 @@ import static org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuery
 /**
  * Parser for the standard Lucene syntax
  */
-@SuppressWarnings("unused") public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
+@SuppressWarnings({"unused","null"}) public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
   public StandardSyntaxParser() {
     this(new FastCharStream(Reader.nullReader()));
   }
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java
index 8cd3fad..d7a6888 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/MultiFieldQueryNodeProcessor.java
@@ -81,7 +81,7 @@ public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl {
               "StandardQueryConfigHandler.ConfigurationKeys.MULTI_FIELDS should be set on the QueryConfigHandler");
         }
 
-        if (fields != null && fields.length > 0) {
+        if (fields.length > 0) {
           fieldNode.setField(fields[0]);
 
           if (fields.length == 1) {
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
index c90c362..9b5bddb 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
@@ -46,7 +46,7 @@ import org.apache.lucene.queryparser.charstream.FastCharStream;
  *  to two terms may appear between a and b.  </p>
  */
 
-@SuppressWarnings("unused") public class QueryParser implements QueryParserConstants {
+@SuppressWarnings({"unused","null"}) public class QueryParser implements QueryParserConstants {
   static final int MINIMUM_PREFIX_LENGTH = 3;
   static final int MINIMUM_CHARS_IN_TRUNC = 3;
   static final String TRUNCATION_ERROR_MESSAGE = "Too unrestrictive truncation: ";
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java
index ce7f19c..1422d91 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndTruncQuery.java
@@ -101,7 +101,7 @@ public class SrndTruncQuery extends SimpleTerm {
         }
 
         while (text != null) {
-          if (text != null && StringHelper.startsWith(text, prefixRef)) {
+          if (StringHelper.startsWith(text, prefixRef)) {
             String textString = text.utf8ToString();
             matcher.reset(textString.substring(prefixLength));
             if (matcher.matches()) {
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
index 09aaf8f..9ef0ca8 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
@@ -550,6 +550,7 @@ public class TestStressNRTReplication extends LuceneTestCase {
 
   /** Launches a child "server" (separate JVM), which is either primary or replica node */
   @SuppressForbidden(reason = "ProcessBuilder requires java.io.File for CWD")
+  @SuppressWarnings("null")
   NodeProcess startNode(final int id, Path indexPath, boolean isPrimary, long forcePrimaryVersion)
       throws IOException {
     nodeTimeStamps[id] = System.nanoTime();
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
index ee98488..1a28d47 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/LatLonPointPrototypeQueries.java
@@ -102,11 +102,9 @@ public class LatLonPointPrototypeQueries {
         }
         totalHits += points.getDocCount();
         BKDReader reader = (BKDReader) points;
-        if (reader != null) {
-          readers.add(reader);
-          docBases.add(leaf.docBase);
-          liveDocs.add(leaf.reader().getLiveDocs());
-        }
+        readers.add(reader);
+        docBases.add(leaf.docBase);
+        liveDocs.add(leaf.reader().getLiveDocs());
       }
     }
 
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
index 51d8152..b13bbfe 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoDegeneratePath.java
@@ -100,9 +100,6 @@ class GeoDegeneratePath extends GeoBasePath {
     for (final GeoPoint end : points) {
       if (lastPoint != null) {
         final Plane normalizedConnectingPlane = new Plane(lastPoint, end);
-        if (normalizedConnectingPlane == null) {
-          continue;
-        }
         segments.add(new PathSegment(planetModel, lastPoint, end, normalizedConnectingPlane));
       }
       lastPoint = end;
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
index 227f2e7..4e8521a 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardPath.java
@@ -119,9 +119,6 @@ class GeoStandardPath extends GeoBasePath {
     for (final GeoPoint end : points) {
       if (lastPoint != null) {
         final Plane normalizedConnectingPlane = new Plane(lastPoint, end);
-        if (normalizedConnectingPlane == null) {
-          continue;
-        }
         segments.add(
             new PathSegment(planetModel, lastPoint, end, normalizedConnectingPlane, cutoffOffset));
       }
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
index e7fc7f0..9b914b4 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
@@ -230,19 +230,17 @@ public class SidedPlane extends Plane implements Membership {
       final Vector insidePoint, final Vector point1, final Vector point2, final Vector point3) {
     SidedPlane rval = null;
 
-    if (rval == null) {
-      try {
-        final Vector planeNormal =
-            new Vector(
-                point1.x - point2.x,
-                point1.y - point2.y,
-                point1.z - point2.z,
-                point2.x - point3.x,
-                point2.y - point3.y,
-                point2.z - point3.z);
-        rval = new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point2));
-      } catch (IllegalArgumentException e) {
-      }
+    try {
+      final Vector planeNormal =
+          new Vector(
+              point1.x - point2.x,
+              point1.y - point2.y,
+              point1.z - point2.z,
+              point2.x - point3.x,
+              point2.y - point3.y,
+              point2.z - point3.z);
+      rval = new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point2));
+    } catch (IllegalArgumentException e) {
     }
 
     if (rval == null) {
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
index 860de66..9bd4d32 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
@@ -2287,7 +2287,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
         if (docValues.docID() < i) {
           docValues.nextDoc();
         }
-        if (docValues != null && stringValues.length > 0) {
+        if (stringValues.length > 0) {
           assertEquals(i, docValues.docID());
           for (int j = 0; j < stringValues.length; j++) {
             assert docValues != null;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
index 8e48269..993ed28 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
@@ -260,27 +260,25 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
           }
           break;
         }
-        if (writer != null) {
-          try {
-            addDoc(writer);
-          } catch (Throwable t) {
-            hitException = true;
-            System.out.println(
-                "Stress Test Index Writer: addDoc hit unexpected exception: " + t.toString());
-            t.printStackTrace(System.out);
-            System.out.println(toString(baos));
-            break;
-          }
-          try {
-            writer.close();
-          } catch (Throwable t) {
-            hitException = true;
-            System.out.println(
-                "Stress Test Index Writer: close hit unexpected exception: " + t.toString());
-            t.printStackTrace(System.out);
-            System.out.println(toString(baos));
-            break;
-          }
+        try {
+          addDoc(writer);
+        } catch (Throwable t) {
+          hitException = true;
+          System.out.println(
+              "Stress Test Index Writer: addDoc hit unexpected exception: " + t.toString());
+          t.printStackTrace(System.out);
+          System.out.println(toString(baos));
+          break;
+        }
+        try {
+          writer.close();
+        } catch (Throwable t) {
+          hitException = true;
+          System.out.println(
+              "Stress Test Index Writer: close hit unexpected exception: " + t.toString());
+          t.printStackTrace(System.out);
+          System.out.println(toString(baos));
+          break;
         }
       }
     }