poorbarcode commented on code in PR #25293:
URL: https://github.com/apache/pulsar/pull/25293#discussion_r2903040354
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TableView.java:
##########
@@ -48,7 +49,20 @@ public class TableView<T> {
protected final Function<TopicName, CompletableFuture<Reader<T>>>
readerCreator;
private final Map<String, T> snapshots = new ConcurrentHashMap<>();
private final long clientOperationTimeoutMs;
- private final SimpleCache<NamespaceName, Reader<T>> readers;
+ private final SimpleCache<NamespaceName, CompletableFuture<Reader<T>>>
readers;
+ private final Consumer<CompletableFuture<Reader<T>>> expiration =
readerFuture -> {
+ if (!readerFuture.isDone()) {
+ readerFuture.handle((reader, t) -> {
+ if (reader != null) {
+ closeReader(reader);
+ }
+ return null;
+ });
+ } else if (!readerFuture.isCompletedExceptionally()) {
+ // Since the future has done, it will not wait anymore.
+ closeReader(readerFuture.join());
Review Comment:
> the future completes exceptionally and should not try to close anything
It seems that this is very difficult to achieve because you cannot determine
whether a non-existent object has ever been closed.
Added a simple test to cover the case that failed to create reader
--
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]