@Override
    public void destroy() {
        if (logger.isInfoEnabled()) {
            logger.info("Destroy registry:" + getUrl());
        }
        Set<URL> destroyRegistered = new HashSet<>(getRegistered());
        if (!destroyRegistered.isEmpty()) {
            for (URL url : new HashSet<>(destroyRegistered)) {
                if (url.getParameter(DYNAMIC_KEY, true)) {
                    try {
                        unregister(url);
                        if (logger.isInfoEnabled()) {
                            logger.info("Destroy unregister url " + url);
                        }
                    } catch (Throwable t) {
                        // 1-8: Failed to unregister / unsubscribe url on destroy.
                        logger.warn(
                                REGISTRY_FAILED_DESTROY_UNREGISTER_URL,
                                "",
                                "",
                                "Failed to unregister url " + url + " to registry " + getUrl() + " on destroy, cause: "
                                        + t.getMessage(),
                                t);
                    }
                }
            }
        }
        Map<URL, Set<NotifyListener>> destroySubscribed = new HashMap<>(getSubscribed());
        if (!destroySubscribed.isEmpty()) {
            for (Map.Entry<URL, Set<NotifyListener>> entry : destroySubscribed.entrySet()) {
                URL url = entry.getKey();
                for (NotifyListener listener : entry.getValue()) {
                    try {
                        unsubscribe(url, listener);
                        if (logger.isInfoEnabled()) {
                            logger.info("Destroy unsubscribe url " + url);
                        }
                    } catch (Throwable t) {
                        // 1-8: Failed to unregister / unsubscribe url on destroy.
                        logger.warn(
                                REGISTRY_FAILED_DESTROY_UNREGISTER_URL,
                                "",
                                "",
                                "Failed to unsubscribe url " + url + " to registry " + getUrl() + " on destroy, cause: "
                                        + t.getMessage(),
                                t);
                    }
                }
            }
        }
        registryManager.removeDestroyedRegistry(this);
    }
@Test
    void destroyTest() {
        abstractRegistry.register(testUrl);
        abstractRegistry.subscribe(testUrl, listener);
        Assertions.assertEquals(1, abstractRegistry.getRegistered().size());
        Assertions.assertEquals(1, abstractRegistry.getSubscribed().get(testUrl).size());
        // delete listener and register
        abstractRegistry.destroy();
        Assertions.assertEquals(0, abstractRegistry.getRegistered().size());
        Assertions.assertEquals(0, abstractRegistry.getSubscribed().get(testUrl).size());
    }