dweiss commented on code in PR #11998:
URL: https://github.com/apache/lucene/pull/11998#discussion_r1045027949


##########
lucene/test-framework/src/java/org/apache/lucene/tests/index/AssertingLeafReader.java:
##########
@@ -113,34 +116,84 @@ public Fields getTermVectors(int docID) throws 
IOException {
     return fields == null ? null : new AssertingFields(fields);
   }
 
+  @Override
+  public TermVectors termVectors() throws IOException {
+    return new AssertingTermVectors(super.termVectors());
+  }
+
+  @Override
+  public StoredFields storedFields() throws IOException {
+    return new AssertingStoredFields(super.storedFields());
+  }
+
+  /** Wraps a StoredFields but with additional asserts */
+  public static class AssertingStoredFields extends StoredFields {
+    private final StoredFields in;
+    private final Thread creationThread = Thread.currentThread();
+
+    public AssertingStoredFields(StoredFields in) {
+      this.in = in;
+    }
+
+    @Override
+    public void document(int docID, StoredFieldVisitor visitor) throws 
IOException {
+      assertThread("StoredFields", creationThread);
+      in.document(docID, visitor);
+    }
+  }
+
+  /** Wraps a TermVectors but with additional asserts */
+  public static class AssertingTermVectors extends TermVectors {
+    private final TermVectors in;
+    private final Thread creationThread = Thread.currentThread();
+
+    public AssertingTermVectors(TermVectors in) {
+      this.in = in;
+    }
+
+    @Override
+    public Fields get(int doc) throws IOException {
+      assertThread("TermVectors", creationThread);
+      Fields fields = in.get(doc);
+      return fields == null ? null : new AssertingFields(fields);
+    }
+  }
+
   /** Wraps a Fields but with additional asserts */
   public static class AssertingFields extends FilterFields {
+    private final Thread creationThread = Thread.currentThread();

Review Comment:
   +1. It's not just thread-safety but strict thread-confinement. I assume 
we're fine with this stricter rule within tests/codebase. I don't see any 
reason why these objects should be passed around (?).



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to