{"record":{"id":"006838d60f0a357a","repo":"alibaba/spring-ai-alibaba","slug":"cancel-is-not-implemented-yet","errorCode":null,"errorMessage":"cancel is not implemented yet!","messagePattern":"cancel is not implemented yet!","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/async/internal/reactive/GeneratorPublisher.java","lineNumber":69,"sourceCode":"\t\t\t/**\n\t\t\t * Requests more elements from the upstream Publisher.\n\t\t\t *\n\t\t\t * <p>\n\t\t\t * The Publisher calls this method to indicate that it wants more items. The\n\t\t\t * parameter {@code n} specifies the number of additional items requested.\n\t\t\t * @param n the number of items to request, a count greater than zero\n\t\t\t */\n\t\t\t@Override\n\t\t\tpublic void request(long n) {\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Cancels the operation.\n\t\t\t * @throws UnsupportedOperationException if the method is not yet implemented.\n\t\t\t */\n\t\t\t@Override\n\t\t\tpublic void cancel() {\n\t\t\t\tthrow new UnsupportedOperationException(\"cancel is not implemented yet!\");\n\t\t\t}\n\t\t});\n\n\t\tdelegate.forEachAsync(subscriber::onNext).thenAccept(value -> {\n\t\t\tsubscriber.onComplete();\n\t\t}).exceptionally(ex -> {\n\t\t\tsubscriber.onError(ex);\n\t\t\treturn null;\n\t\t}).join();\n\t}\n\n}\n","sourceCodeStart":51,"sourceCodeEnd":82,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/async/internal/reactive/GeneratorPublisher.java#L51-L82","documentation":"GeneratorPublisher wraps a Generator as a reactive Publisher, but cancellation of the underlying async operation is not yet supported in this library. Calling cancel() unconditionally throws UnsupportedOperationException. It is a placeholder API indicating an unfinished feature.","triggerScenarios":"Obtaining the Subscribable/publishable wrapper around a Generator-based async graph stream and invoking its cancel() method (e.g. aborting a streaming run mid-flight).","commonSituations":"Developers building reactive streaming UIs who try to abort a long-running generator-driven graph execution on user disconnect or timeout.","solutions":["Do not call cancel(); let the generator run to completion or close the subscription instead","Stop consuming the stream (dispose the subscription) and rely on downstream cancellation of forEachAsync","Upgrade the library version in case cancellation support has been added","Wrap cancel() usage behind a capability check and degrade gracefully when unsupported"],"exampleFix":"// before\npublisher.cancel();\n// after\nif (publisher.supportsCancel()) { publisher.cancel(); } else { subscription.dispose(); }","handlingStrategy":"try-catch","validationCode":"boolean cancelable = !(publisher instanceof GeneratorPublisher);","typeGuard":"boolean supportsCancel(Object p) { return !(p instanceof com.alibaba.cloud.ai.graph.async.internal.reactive.GeneratorPublisher); }","tryCatchPattern":"try { publisher.cancel(); } catch (UnsupportedOperationException e) { subscription.dispose(); }","preventionTips":["Avoid depending on cancel() for generator-backed streams","Dispose subscriptions instead of cancelling","Check library release notes for cancellation support"],"tags":["reactive","unsupported-operation","async"],"backgroundTag":"method-not-implemented","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}