javanna commented on code in PR #17020:
URL: https://github.com/apache/lucene/pull/17020#discussion_r4562899328


##########
lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java:
##########
@@ -105,6 +106,18 @@ public void testClone() throws Exception {
     assertNotSame(buf, copy.buffer());
   }
 
+  public void testCloneDoesNotRetainBytesOfPreviousTerm() {
+    CharTermAttributeImpl t = new CharTermAttributeImpl();
+    String longTerm = "a".repeat(10_000);
+    t.append(longTerm);
+    t.getBytesRef();
+    t.setEmpty().append("hello");
+    CharTermAttributeImpl copy = t.clone();
+    assertEquals(new BytesRef("hello"), copy.getBytesRef());
+    long ramUsed = RamUsageTester.ramUsed(copy);
+    assertTrue("clone uses " + ramUsed + " bytes", ramUsed < 
longTerm.length());

Review Comment:
   do we need to check ram used in this test? Could we instead assert on the 
length of the builder?



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