BewareMyPower commented on code in PR #24658:
URL: https://github.com/apache/pulsar/pull/24658#discussion_r2296718051
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -526,32 +533,41 @@ private void
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
});
}
- private void cleanCacheAndCloseReader(@NonNull NamespaceName namespace,
boolean cleanOwnedBundlesCount) {
- cleanCacheAndCloseReader(namespace, cleanOwnedBundlesCount, false);
+ private void cleanCache(@NonNull NamespaceName namespace, boolean
cleanOwnedBundlesCount,
+ boolean closeReaderCache) {
+ cleanCache(namespace, cleanOwnedBundlesCount, false, closeReaderCache);
}
- private void cleanCacheAndCloseReader(@NonNull NamespaceName namespace,
boolean cleanOwnedBundlesCount,
- boolean cleanWriterCache) {
+ private void cleanCache(@NonNull NamespaceName namespace, boolean
cleanOwnedBundlesCount,
+ boolean cleanWriterCache, boolean
cleanReaderCache) {
if (cleanWriterCache) {
writerCaches.synchronous().invalidate(namespace);
}
- CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> readerFuture
= readerCaches.remove(namespace);
if (cleanOwnedBundlesCount) {
ownedBundlesCountPerNamespace.remove(namespace);
}
- if (readerFuture != null && !readerFuture.isCompletedExceptionally()) {
- readerFuture.thenCompose(SystemTopicClient.Reader::closeAsync)
- .exceptionally(ex -> {
- log.warn("[{}] Close change_event reader fail.",
namespace, ex);
- return null;
- });
+
+ if (!cleanReaderCache) {
+ return;
Review Comment:
I realized they are coupled:
```java
return
policyCacheInitMap.computeIfAbsent(namespace, (k) -> {
final
CompletableFuture<SystemTopicClient.Reader<PulsarEvent>>
readerCompletableFuture =
createSystemTopicClient(namespace);
readerCaches.put(namespace,
readerCompletableFuture);
```
It's really not a good design.
--
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]