nodece commented on code in PR #22344:
URL: https://github.com/apache/pulsar/pull/22344#discussion_r1538509430
##########
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java:
##########
@@ -2642,10 +2642,10 @@ public void testGetNumberOfEntriesInStorage() throws
Exception {
managedLedger.addEntry(("entry-" + i).getBytes(Encoding));
}
- //trigger ledger rollover and wait for the new ledger created
- Field stateUpdater = ManagedLedgerImpl.class.getDeclaredField("state");
- stateUpdater.setAccessible(true);
- stateUpdater.set(managedLedger, ManagedLedgerImpl.State.LedgerOpened);
+ // trigger ledger rollover and wait for the new ledger created
+ Awaitility.await().untilAsserted(() -> {
+ assertEquals("LedgerOpened",
WhiteboxImpl.getInternalState(managedLedger, "state").toString());
Review Comment:
```suggestion
assertEquals(managedLedger.getState(), State.LedgerOpened);
```
WhiteboxImpl.getInternalState is not a good way. When this variable name is
changed, it is easy to miss this point.
I prefer to call the method, you can also add the `@VisibleForTesting` to
the test method.
--
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]