tolbertam commented on code in PR #2045:
URL:
https://github.com/apache/cassandra-java-driver/pull/2045#discussion_r2975977202
##########
core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlPrepareAsyncProcessor.java:
##########
@@ -64,14 +63,17 @@ public CqlPrepareAsyncProcessor() {
}
public CqlPrepareAsyncProcessor(@NonNull Optional<? extends
DefaultDriverContext> context) {
- this(context, Functions.identity());
+ this(context, CacheBuilder::weakValues);
}
protected CqlPrepareAsyncProcessor(
Optional<? extends DefaultDriverContext> context,
Function<CacheBuilder<Object, Object>, CacheBuilder<Object, Object>>
decorator) {
- CacheBuilder<Object, Object> baseCache =
CacheBuilder.newBuilder().weakValues();
+ // CASSJAVA-104
+ // Note that the base cache does NOT use weak values like the one-arg
constructor it previously
+ // does!
+ CacheBuilder<Object, Object> baseCache = CacheBuilder.newBuilder();
Review Comment:
```suggestion
// Use weakValues to evict prepared statements from the cache as soon
are they are
// no longer referenced elsewhere.
this(context, CacheBuilder::weakValues);
}
protected CqlPrepareAsyncProcessor(
Optional<? extends DefaultDriverContext> context,
Function<CacheBuilder<Object, Object>, CacheBuilder<Object, Object>>
decorator) {
CacheBuilder<Object, Object> baseCache = CacheBuilder.newBuilder();
```
Was a little confused by this. It looks like the 1-argument constructor is
used by the codebase, and the 2 argument constructor is used by tests, by
moving the weakValues to the 1arg constructor, this allows the tests to work
around the cache values being evicted as soon as they are no longer referenced
elsewhere.
Think it would be better to just add a comment in the 1-arg constructor
where weakValue is declared so it will be more clear why it's used there.
--
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]