lhotari edited a comment on pull request #14373:
URL: https://github.com/apache/pulsar/pull/14373#issuecomment-1055500489
> @lhotari In this PR, we need ensure ` objCache.getIfCached(key1)` only
return `Optional.empty()` or correct value.
>
> If we use `Awaitility.await().untilAsserted(...);` here, when
`objCache.getIfCached(key1)` return a wrong value it still retry.
>
> ```java
> Awaitility.await().untilAsserted(() -> {
> assertEquals(objCache.getIfCached(key1), Optional.of(v));
> });
> ```
>
> If `Awaitility` can do what I said, please tell me. Thanks! :-)
I don't see a reason why Awaitility couldn't handle this. Sometimes it's
necessary to add `.ignoreExceptions()` to the Awaitility configuration. This is
needed if the assertion throws some other exception than an AssertionError.
Did you try
```java
Awaitility.await().ignoreExceptions().untilAsserted(() -> {
assertEquals(objCache.getIfCached(key1), Optional.of(v));
});
```
I'm also wondering the logic in `retryStrategically`. It looks like the
check will always pass when `i == (retryCount - 1)`. Perhaps that's the reason
why it "works"? @Demogorgon314 please check
https://github.com/apache/pulsar/blob/8264414547cd5e837c0c8a625d7346c03353b43a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java#L611-L620
--
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]