Skip to content

Commit 8be8335

Browse files
author
Claude (on behalf of Steven Schlansker)
committed
test(format): reset leaked ListLazyElemInner.check flag in finally
The lazy-list test sets the static check flag to assert that only the accessed element is constructed, but never reset it. Left true, the flag leaks into any later test that decodes a ListLazyElemInner through its globally-registered codec, where a non-42 value would trip the constructor assertion spuriously. Reset it in a finally so it cannot escape the test.
1 parent 88f088b commit 8be8335

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

java/fory-format/src/test/java/org/apache/fory/format/encoder/ImplementInterfaceTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,19 @@ public void testListElementsLazy() {
470470
new ListLazyElemInner(4)));
471471
final RowEncoder<ListLazyElemOuter> encoder = Encoders.bean(ListLazyElemOuter.class);
472472
final BinaryRow row = encoder.toRow(bean1);
473+
// Only the accessed element (index 2, value 42) should be constructed; the constructor's check
474+
// guard asserts that. Reset it in finally so the flag never leaks into another test decoding a
475+
// ListLazyElemInner through its globally-registered codec.
473476
ListLazyElemInner.check = true;
474-
final MemoryBuffer buffer = MemoryUtils.wrap(row.toBytes());
475-
row.pointTo(buffer, 0, buffer.size());
476-
final ListLazyElemOuter deserializedBean = encoder.fromRow(row);
477-
Assert.assertEquals(deserializedBean.f1().get(2).f1(), 42);
478-
Assert.assertEquals(deserializedBean.f1().get(3), null);
477+
try {
478+
final MemoryBuffer buffer = MemoryUtils.wrap(row.toBytes());
479+
row.pointTo(buffer, 0, buffer.size());
480+
final ListLazyElemOuter deserializedBean = encoder.fromRow(row);
481+
Assert.assertEquals(deserializedBean.f1().get(2).f1(), 42);
482+
Assert.assertEquals(deserializedBean.f1().get(3), null);
483+
} finally {
484+
ListLazyElemInner.check = false;
485+
}
479486
}
480487

481488
public interface IgnoredMethods {

0 commit comments

Comments
 (0)