You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main issue is that it uses `cache.size()`.
While it may not be a bad idea to use that, the documentation
mentions that it returns an approximate size of the cache.
`CqlPrepareAsyncProcessor` actually invalidates the prepare requests that
finish with errors (see `process` method). Such is the case with this test.
The `PreparedStatement` gets cached for a really short period and then
invalidated because of the exception.
Depending on the exact timings it would be correct for the cache to report
either size 0 or size 1. Additionally the moment when the size gets updated
may differ from the moments modifications to the cache contents are made.
This change is a quick workaround that should
achieve the same end result as the setup in PreparedStatementCachingIT.
Here we use reflection to forcibly change the cache used by the
request processor. Same type, but has removal listener added to it.
Instead of relying on the uncertain cache size the test will listen for
the removal from the cache.
The alternative would be reimplementing similar setup as in
PreparedStatementCachingIT with some changes. That means
having a test version of DefaultDriverContext, CqlPrepareAsyncProcessor,
SessionBuilder and necessary methods, so that we could inject the listener
without the reflection.
The other option is moving this test method to the PreparedStatementCachingIT,
but then the cache's remove callback which is used there throughout the class
needs to be adjusted specifically for this method.
0 commit comments