Skip to content

Apache Lucene open-source search software

Avoid NPEx if the end of the stream has been reached without reading any characters (#12611)

Piotrek Żygiełodfff1e635805
diff --git a/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java b/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java
index 690144dad3f..67fcd762be1 100644
--- a/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java
+++ b/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java
@@ -195,7 +195,7 @@ public class SearchFiles {
+ " total matching documents collected.");
System.out.println("Collect more (y/n) ?");
String line = in.readLine();
- if (line.length() == 0 || line.charAt(0) == 'n') {
+ if (line == null || line.length() == 0 || line.charAt(0) == 'n') {
break;
}
@@ -241,7 +241,7 @@ public class SearchFiles {
System.out.println("(q)uit or enter number to jump to a page.");
String line = in.readLine();
- if (line.length() == 0 || line.charAt(0) == 'q') {
+ if (line == null || line.length() == 0 || line.charAt(0) == 'q') {
quit = true;
break;
}