Skip to content

Commit 78e65bb

Browse files
pradithya ariafeast-ci-bot
authored andcommitted
Create scheduledExecutorService as field instead of local variable to avoid getting GC-ed (#189)
1 parent 1cad00a commit 78e65bb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

serving/src/main/java/feast/serving/config/ServingApiConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
public class ServingApiConfiguration implements WebMvcConfigurer {
4848

4949
@Autowired private ProtobufJsonFormatHttpMessageConverter protobufConverter;
50+
private ScheduledExecutorService scheduledExecutorService =
51+
Executors.newSingleThreadScheduledExecutor();
5052

5153
@Bean
5254
public AppConfig getAppConfig(
@@ -67,14 +69,12 @@ public SpecStorage getCoreServiceSpecStorage(
6769
@Value("${feast.core.host}") String coreServiceHost,
6870
@Value("${feast.core.grpc.port}") String coreServicePort,
6971
@Value("${feast.cacheDurationMinute}") int cacheDurationMinute) {
70-
ScheduledExecutorService scheduledExecutorService =
71-
Executors.newSingleThreadScheduledExecutor();
7272
final CachedSpecStorage cachedSpecStorage =
7373
new CachedSpecStorage(new CoreService(coreServiceHost, Integer.parseInt(coreServicePort)));
7474

7575
// reload all specs including new ones periodically
7676
scheduledExecutorService.schedule(
77-
() -> cachedSpecStorage.populateCache(), cacheDurationMinute, TimeUnit.MINUTES);
77+
cachedSpecStorage::populateCache, cacheDurationMinute, TimeUnit.MINUTES);
7878

7979
// load all specs during start up
8080
try {

0 commit comments

Comments
 (0)