void removeSubscription(final Subscription subscription)
    {
        clientLock.lock();
        try
        {
            if (isTerminating || isClosed)
            {
                return;
            }

            if (!subscription.isClosed())
            {
                ensureNotReentrant();

                subscription.internalClose(EXPLICIT_CLOSE_LINGER_NS);
                final long registrationId = subscription.registrationId();
                if (subscription == resourceByRegIdMap.remove(registrationId))
                {
                    asyncCommandIdSet.add(driverProxy.removeSubscription(registrationId));
                }
            }
        }
        finally
        {
            clientLock.unlock();
        }
    }
@Test
    void shouldThrowAeronExceptionOnAttemptToRemoveWrongResourceUsingSubscriptionRegistrationId()
    {
        final long registrationId = 42;
        conductor.resourceByRegIdMap.put(registrationId, "test resource");

        final AeronException exception =
            assertThrowsExactly(AeronException.class, () -> conductor.removeSubscription(registrationId));
        assertEquals("ERROR - registration id is not a Subscription: String", exception.getMessage());
    }