mikemccand commented on code in PR #15702:
URL: https://github.com/apache/lucene/pull/15702#discussion_r2799076987


##########
lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java:
##########
@@ -138,7 +138,7 @@ public BytesRefHash(ByteBlockPool pool, int capacity, 
BytesStartArray bytesStart
     bytesStart = bytesStartArray.init();
     final Counter bytesUsed = bytesStartArray.bytesUsed();
     this.bytesUsed = bytesUsed == null ? Counter.newCounter() : bytesUsed;
-    bytesUsed.addAndGet(hashSize * (long) Integer.BYTES);
+    this.bytesUsed.addAndGet(hashSize * (long) Integer.BYTES);

Review Comment:
   Whoa, nice catch, thank you @tyronecai  and IntelliJ!  I wonder if there is 
a low-false-positive (high signal to noise ratio) static checker we could turn 
on in Lucene's CI builds to catch this kind of lurking bug?
   
   I think it indeed must be that all the `BytesStartArrays` used here have a 
non-null `bytesUsed`?  In which case +1 to make it required not `null` (change 
to `assert`).  This is technically a public API, but `@lucene.internal` (well, 
`BytesRefHash` is), so we are free to suddenly change API/requirement here.



-- 
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: [email protected]

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