{"record":{"id":"2da1d91547bff166","repo":"apache/pulsar","slug":"cause","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/MultiTopicQueueConsumer.java","lineNumber":362,"sourceCode":"            return;\n        }\n        action.accept(state.consumer);\n    }\n\n    @Override\n    public AsyncQueueConsumer<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    @Override\n    public CompletableFuture<Message<T>> receiveAsync() {\n        return mux.receiveAsync();\n    }\n\n    @Override\n    public 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).","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/MultiTopicQueueConsumer.java#L344-L380","documentation":"Thrown by MultiTopicQueueConsumer.close() when closeAsync()'s future completed exceptionally. The original failure is unwrapped from ExecutionException and rethrown as a PulsarClientException with the cause attached. It surfaces any error that occurred while closing per-topic consumers.","triggerScenarios":"closeAsync() fails because an underlying per-topic consumer or client throws during close — broker connection lost, per-topic close errors, or subscription close failures.","commonSituations":"Closing consumers during a broker outage or network partition; client already closed; timeouts on the broker while unsubscribing.","solutions":["Inspect e.getCause() (the PulsarClientException) to identify the failing topic/consumer","Retry close() once the connection is re-established; close is generally idempotent-safe to retry","Use closeAsync() and log per-topic failures instead of letting close() throw"],"exampleFix":"// before\nconsumer.close(); // may throw with opaque cause\n// after\ntry {\n    consumer.close();\n} catch (PulsarClientException e) {\n    log.warn(\"close failed: {}\", e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { consumer.close(); } catch (PulsarClientException e) { log.warn(\"close failed: {}\", e.getCause()); }","preventionTips":["Check broker connectivity before closing during outages","Retry close after reconnection; log the wrapped 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"}