Class CancellationRegistration

java.lang.Object
com.hedera.hashgraph.sdk.CancellationRegistration
All Implemented Interfaces:
AutoCloseable

public final class CancellationRegistration extends Object implements AutoCloseable
The handle returned by Cancellation.onCancel(Runnable), used to stop observing.

Releasing is not optional. An application that holds one CancellationSource across many calls — "cancel everything on logout", which is the use the type exists for — would otherwise accumulate one dead closure per exchange for the lifetime of that source. It is the addEventListener without removeEventListener leak, and a single-use rule would not fix it because nothing can enforce one.

Implements AutoCloseable so it can be released from a try-with-resources block; close() is exactly release() and throws nothing.