muse-dev[bot] commented on a change in pull request #2317:
URL: https://github.com/apache/lucene-solr/pull/2317#discussion_r571784231



##########
File path: 
lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
##########
@@ -839,4 +839,38 @@ public void testMismatchedFields() throws Exception {
     IOUtils.close(iw, ir, everything);
     IOUtils.close(dirs);
   }
+
+  public void testPrefetch() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig config = newIndexWriterConfig().setCodec(getCodec());
+    IndexWriter writer = new IndexWriter(dir, config);
+    int numDocs = atLeast(100);
+    Map<Integer, Document> docs = new HashMap<>();
+    for (int i = 0; i < numDocs; i++) {
+      Document doc = new Document();
+      int numFields = random().nextInt(rarely() ? 1000 : 100);
+      doc.add(new StringField("num_fields", Integer.toString(numFields), 
Store.NO));
+      for (int f = 0; f < numFields; f++) {
+        String str = "doc=" + i + "f=" + f;
+        doc.add(new StringField("field-" + f, str, Store.YES));
+      }
+      writer.addDocument(doc);
+      docs.put(i, doc);
+    }
+    final DirectoryReader reader = new 
RandomPrefetchStoredFieldsCodecDirectoryReader(DirectoryReader.open(writer));
+    int iters = atLeast(100);
+    for (int i = 0; i < iters; i++) {
+      int docId = random().nextInt(numDocs);
+      int numFields = 
Integer.parseInt(docs.get(docId).getField("num_fields").stringValue());

Review comment:
       *NULL_DEREFERENCE:*  object returned by 
`docs.get(valueOf(docId)).getField("num_fields")` could be null and is 
dereferenced at line 864.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to