{"record":{"id":"8146d6b79152b052","repo":"aeron-io/aeron","slug":"registration-id-is-not-a-subscription-simplename","errorCode":null,"errorMessage":"registration id is not a Subscription: <simpleName>","messagePattern":"registration id is not a Subscription: <simpleName>","errorType":"exception","errorClass":"AeronException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ClientConductor.java","lineNumber":861,"sourceCode":"        }\n    }\n\n    void removeSubscription(final long subscriptionRegistrationId)\n    {\n        clientLock.lock();\n        try\n        {\n            if (NULL_VALUE == subscriptionRegistrationId || isTerminating || isClosed)\n            {\n                return;\n            }\n\n            ensureNotReentrant();\n\n            final Object resource = resourceByRegIdMap.get(subscriptionRegistrationId);\n            if (resource != null && !(resource instanceof PendingSubscription || resource instanceof Subscription))\n            {\n                throw new AeronException(\"registration id is not a Subscription: \" +\n                    resource.getClass().getSimpleName());\n            }\n\n            final Subscription subscription = resource instanceof PendingSubscription ?\n                ((PendingSubscription)resource).subscription : (Subscription)resource;\n            if (null != subscription)\n            {\n                resourceByRegIdMap.remove(subscriptionRegistrationId);\n                subscription.internalClose(EXPLICIT_CLOSE_LINGER_NS);\n            }\n\n            if (asyncCommandIdSet.remove(subscriptionRegistrationId) || null != subscription)\n            {\n                asyncCommandIdSet.add(driverProxy.removeSubscription(subscriptionRegistrationId));\n            }\n        }\n        finally\n        {","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ClientConductor.java#L843-L879","documentation":"Thrown by ClientConductor when removing a subscription by registration id and the id maps to an existing resource that is neither a Subscription nor a PendingSubscription. The conductor keeps resource type checks symmetric with removePublication to prevent releasing the wrong object.","triggerScenarios":"Calling removeSubscription(subscriptionRegistrationId) with an id belonging to a Publication, Counter, or image-related registration.","commonSituations":"Storing ids in generic long variables or collections; concurrency refactors that shuffle which id is which; logging/telemetry code echoing the wrong id back into remove calls.","solutions":["Use the registration id from the Subscription (or its future) returned by addSubscription.","Call removePublication/removeCounter for non-subscription ids.","Keep ids in typed wrappers (e.g. record SubscriptionHandle(long regId)) to prevent mix-ups."],"exampleFix":"// before\nlong id = client.addPublication(channel, streamId).registrationId();\nclient.removeSubscription(id); // AeronException\n// after\nlong subId = client.addSubscription(channel, streamId).registrationId();\nclient.removeSubscription(subId);","handlingStrategy":"try-catch","validationCode":"if (!(resource instanceof Subscription)) throw new IllegalStateException(\"id is not a subscription\");\nclient.removeSubscription(subscription.registrationId());","typeGuard":"boolean isSubscriptionRegId(long regId) { Object r = resourceByRegId(regId); return r instanceof Subscription || r instanceof PendingSubscription; }","tryCatchPattern":"try { client.removeSubscription(regId); } catch (AeronException e) { log.warn(\"reg id {} is not a Subscription: {}\", regId, e.getMessage()); }","preventionTips":["Pair each add call with its matching remove call in the same scope.","Name id variables after their resource type.","Keep a typed handle class around Subscription/Publication ids."],"tags":["java","aeron","client-conductor","resource-management"],"backgroundTag":"type-mismatch","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}