Repository: apache/dubbo
File: dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java (Java)

Code before:

    /**
     * Get the instance of {@link DynamicConfiguration} by the specified connection {@link URL} of config-center
     *
     * @param connectionURL of config-center
     * @return non-null
     * @since 2.7.5
     */
    private DynamicConfiguration getDynamicConfiguration(URL connectionURL) {
        String protocol = connectionURL.getProtocol();

        DynamicConfigurationFactory factory =
                ConfigurationUtils.getDynamicConfigurationFactory(applicationModel, protocol);
        return factory.getDynamicConfiguration(connectionURL);
    }

    private volatile boolean registered;

    private final AtomicInteger instanceRefreshScheduleTimes = new AtomicInteger(0);

    /**
     * Indicate that how many threads are updating service
     */
    private final AtomicInteger serviceRefreshState = new AtomicInteger(0);

    private void registerServiceInstance() {
        try {
            registered = true;

            ServiceInstanceMetadataUtils.registerMetadataAndInstance(applicationModel);

        } catch (Exception e) {
            logger.error(
                    CONFIG_REGISTER_INSTANCE_ERROR,
                    "configuration server disconnected",
                    "",
                    "Register instance error.",
                    e);
        }
        if (registered) {
            // scheduled task for updating Metadata and ServiceInstance
            asyncMetadataFuture = frameworkExecutorRepository
                    .getSharedScheduledExecutor()
                    .scheduleWithFixedDelay(
                            () -> {

                                // ignore refresh metadata on stopping
                                if (applicationModel.isDestroyed()) {
                                    return;
                                }


Review comment (suggestion):
`checkState` already uses synchronized, so consider deleting it here.
 

Code after:

    /**
     * Get the instance of {@link DynamicConfiguration} by the specified connection {@link URL} of config-center
     *
     * @param connectionURL of config-center
     * @return non-null
     * @since 2.7.5
     */
    private DynamicConfiguration getDynamicConfiguration(URL connectionURL) {
        String protocol = connectionURL.getProtocol();

        DynamicConfigurationFactory factory =
                ConfigurationUtils.getDynamicConfigurationFactory(applicationModel, protocol);
        return factory.getDynamicConfiguration(connectionURL);
    }

    private volatile boolean registered = false;

    private final AtomicInteger instanceRefreshScheduleTimes = new AtomicInteger(0);

    /**
     * Indicate that how many threads are updating service
     */
    private final AtomicInteger serviceRefreshState = new AtomicInteger(0);

    public synchronized void registerServiceInstance() {
        if (!registered) {
            try {
                registered = true;

                ServiceInstanceMetadataUtils.registerMetadataAndInstance(applicationModel);

            } catch (Exception e) {
                logger.error(
                        CONFIG_REGISTER_INSTANCE_ERROR,
                        "configuration server disconnected",
                        "",
                        "Register instance error.",
                        e);
            }
            // scheduled task for updating Metadata and ServiceInstance
            asyncMetadataFuture = frameworkExecutorRepository
                    .getSharedScheduledExecutor()
                    .scheduleWithFixedDelay(
                            () -> {

                                // ignore refresh metadata on stopping
                                if (applicationModel.isDestroyed()) {
                                    return;
                                }