Avoid blocking on shutdown (#2206)
This commit is contained in:
parent
6e72ee8f6b
commit
30b6244988
|
@ -103,17 +103,22 @@ public class ResourceChangeListenerCacheRefresherImpl implements IResourceChange
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ResourceChangeResult refreshCacheAndNotifyListener(IResourceChangeListenerCache theCache) {
|
public ResourceChangeResult refreshCacheAndNotifyListener(IResourceChangeListenerCache theCache) {
|
||||||
ResourceChangeResult retval = new ResourceChangeResult();
|
ResourceChangeResult retVal = new ResourceChangeResult();
|
||||||
|
if (mySchedulerService.isStopping()) {
|
||||||
|
ourLog.info("Scheduler service is stopping, aborting cache refresh");
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
if (!myResourceChangeListenerRegistry.contains(theCache)) {
|
if (!myResourceChangeListenerRegistry.contains(theCache)) {
|
||||||
ourLog.warn("Requesting cache refresh for unregistered listener {}. Aborting.", theCache);
|
ourLog.warn("Requesting cache refresh for unregistered listener {}. Aborting.", theCache);
|
||||||
return new ResourceChangeResult();
|
return retVal;
|
||||||
}
|
}
|
||||||
SearchParameterMap searchParamMap = theCache.getSearchParameterMap();
|
SearchParameterMap searchParamMap = theCache.getSearchParameterMap();
|
||||||
ResourceVersionMap newResourceVersionMap = myResourceVersionSvc.getVersionMap(theCache.getResourceName(), searchParamMap);
|
ResourceVersionMap newResourceVersionMap = myResourceVersionSvc.getVersionMap(theCache.getResourceName(), searchParamMap);
|
||||||
retval = retval.plus(notifyListener(theCache, newResourceVersionMap));
|
retVal = retVal.plus(notifyListener(theCache, newResourceVersionMap));
|
||||||
|
|
||||||
return retval;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@ -70,4 +71,16 @@ class ResourceChangeListenerCacheRefresherImplTest {
|
||||||
assertTrue(cache.isInitialized());
|
assertTrue(cache.isInitialized());
|
||||||
verifyNoInteractions(listener);
|
verifyNoInteractions(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoActionOnStoppingScheduler() {
|
||||||
|
when(mySchedulerService.isStopping()).thenReturn(true);
|
||||||
|
|
||||||
|
IResourceChangeListener listener = mock(IResourceChangeListener.class);
|
||||||
|
ResourceChangeListenerCache cache = new ResourceChangeListenerCache(PATIENT_RESOURCE_NAME, listener, ourMap, TEST_REFRESH_INTERVAL_MS);
|
||||||
|
myResourceChangeListenerCacheRefresher.refreshCacheAndNotifyListener(cache);
|
||||||
|
|
||||||
|
verify(myResourceVersionSvc, times(0)).getVersionMap(any(), any());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue