Skip to content

Commit

Permalink
Switching to @async (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm9084 authored May 27, 2020
1 parent eb5aca8 commit c13af67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import org.springframework.cloud.endpoint.RefreshEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import com.microsoft.azure.spring.cloud.config.stores.ClientStore;

@Configuration
@ConditionalOnProperty(prefix = AppConfigurationProperties.CONFIG_PREFIX, name = "enabled", matchIfMissing = true)
@EnableAsync
public class AppConfigurationAutoConfiguration {

@Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -23,12 +22,16 @@
import org.springframework.cloud.endpoint.event.RefreshEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.microsoft.azure.spring.cloud.config.stores.ClientStore;
import com.microsoft.azure.spring.cloud.config.stores.ConfigStore;

@Component
public class AppConfigurationRefresh implements ApplicationEventPublisherAware {
private static final Logger LOGGER = LoggerFactory.getLogger(AppConfigurationRefresh.class);

Expand Down Expand Up @@ -71,8 +74,9 @@ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEv
* refreshConfigurations is currently being run elsewhere this method will return
* right away as <b>false</b>.
*/
@Async
public Future<Boolean> refreshConfigurations() {
return CompletableFuture.supplyAsync(() -> refreshStores());
return new AsyncResult<Boolean>(refreshStores());
}

/**
Expand Down

0 comments on commit c13af67

Please sign in to comment.