Add synchronization to SP registry
@@ -56,15 +56,17 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
@Autowired
private DaoConfig myDaoConfig;
- private long myLastRefresh;
+ private volatile long myLastRefresh;
@Autowired
private IFhirResourceDao<SearchParameter> mySpDao;
@Override
public void forceRefresh() {
+ synchronized (this) {
myLastRefresh = 0;
}
+ }
@Override
public Map<String, Map<String, RuntimeSearchParam>> getActiveSearchParams() {
@@ -89,6 +91,8 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
private void refreshCacheIfNeccesary() {
long refreshInterval = 60 * DateUtils.MILLIS_PER_MINUTE;
+ if (System.currentTimeMillis() - refreshInterval > myLastRefresh) {
+ synchronized (this) {
if (System.currentTimeMillis() - refreshInterval > myLastRefresh) {
StopWatch sw = new StopWatch();
@@ -163,6 +167,8 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
ourLog.info("Refreshed search parameter cache in {}ms", sw.getMillis());
}
}
+ }
+ }
private RuntimeSearchParam toRuntimeSp(SearchParameter theNextSp) {
String name = theNextSp.getCode();
