{"record":{"id":"8786b77ab3b158fa","repo":"apache/pulsar","slug":"cause-8786b7","errorCode":null,"errorMessage":"${cause}","messagePattern":"\\$\\{cause\\}","errorType":"exception","errorClass":"org.apache.pulsar.client.impl.v5.PulsarClientException","httpStatus":null,"severity":"error","filePath":"pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/MultiTopicStreamConsumer.java","lineNumber":361,"sourceCode":"            }\n            action.accept(state.consumer, entry.getValue());\n        }\n    }\n\n    @Override\n    public AsyncStreamConsumer<T> async() {\n        return asyncView;\n    }\n\n    @Override\n    public void close() throws PulsarClientException {\n        try {\n            closeAsync().get();\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new PulsarClientException(\"Close interrupted\", e);\n        } catch (ExecutionException e) {\n            throw new PulsarClientException(e.getCause());\n        }\n    }\n\n    CompletableFuture<Void> closeAsync() {\n        if (closed) {\n            return CompletableFuture.completedFuture(null);\n        }\n        closed = true;\n        watcher.close();\n        mux.close();\n        // Cancel pending retries for topics that never finished subscribing (they're not in\n        // perTopic, so the closeTopic loop below wouldn't reach them).\n        retryTimeouts.values().forEach(Timeout::cancel);\n        retryTimeouts.clear();\n        List<CompletableFuture<Void>> closes = new ArrayList<>();\n        for (var topic : new HashSet<>(perTopic.keySet())) {\n            closes.add(closeTopic(topic));\n        }","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/MultiTopicStreamConsumer.java#L343-L379","documentation":"Thrown by MultiTopicStreamConsumer.close() when closeAsync() completes exceptionally; the ExecutionException is unwrapped and rethrown as a PulsarClientException wrapping the original cause. Indicates one or more per-topic stream consumer closes failed.","triggerScenarios":"Broker unreachable during close, per-topic consumer close errors, or client-level failures while shutting down the subscription.","commonSituations":"Closing during network partitions; broker restarts; double-close after client.shutdown().","solutions":["Log and inspect the wrapped cause (e.getCause())","Retry closeAsync() after connectivity is restored","Track closed state and treat a failed close as best-effort during shutdown"],"exampleFix":"// before\nstreamConsumer.close();\n// after\ntry {\n    streamConsumer.close();\n} catch (PulsarClientException e) {\n    log.warn(\"stream close failed: {}\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { streamConsumer.close(); } catch (PulsarClientException e) { log.warn(\"close failed: {}\", e.getCause()); }","preventionTips":["Retry close after connectivity restores","Treat close errors as best-effort during shutdown and log the cause"],"tags":["pulsar","client","close","wrapped-exception"],"backgroundTag":"close-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}