Refactor to prepare for computeIfAbsent.
@@ -8,8 +8,6 @@ import com.yahoo.config.ConfigurationRuntimeException;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.Model;
import com.yahoo.config.provision.ApplicationId;
-import java.util.logging.Level;
-
import com.yahoo.text.AbstractUtf8Array;
import com.yahoo.vespa.config.ConfigCacheKey;
import com.yahoo.vespa.config.ConfigDefinitionKey;
@@ -31,6 +29,7 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository;
import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.yolean.Exceptions;
+import java.util.logging.Level;
import java.util.Objects;
import java.util.Set;
@@ -117,8 +116,18 @@ public class Application implements ModelResult {
metricUpdater.incrementProcTime(System.currentTimeMillis() - start);
return config;
}
+ config = createConfigResponse(configKey, req, responseFactory);
+ cache.put(cacheKey, config, config.getConfigMd5());
+ metricUpdater.setCacheConfigElems(cache.configElems());
+ metricUpdater.setCacheChecksumElems(cache.checkSumElems());
+ return config;
+ } else {
+ return createConfigResponse(configKey, req, responseFactory);
+ }
}
+ private ConfigResponse createConfigResponse(ConfigKey<?> configKey, GetConfigRequest req, ConfigResponseFactory responseFactory) {
+ long start = System.currentTimeMillis();
ConfigDefinition def = getTargetDef(req);
if (def == null) {
metricUpdater.incrementFailedRequests();
@@ -126,19 +135,10 @@ public class Application implements ModelResult {
}
log.log(Level.FINE, () -> TenantRepository.logPre(getId()) + ("Resolving " + configKey + " with config definition " + def));
-
-
var payload = createPayload(configKey, def);
- ConfigResponse configResponse = responseFactory.createResponse(payload.getFirst(),
- applicationGeneration,
- payload.getSecond());
+ var response = responseFactory.createResponse(payload.getFirst(), applicationGeneration, payload.getSecond());
metricUpdater.incrementProcTime(System.currentTimeMillis() - start);
- if (useCache(req)) {
- cache.put(cacheKey, configResponse, configResponse.getConfigMd5());
- metricUpdater.setCacheConfigElems(cache.configElems());
- metricUpdater.setCacheChecksumElems(cache.checkSumElems());
- }
- return configResponse;
+ return response;
}
private Pair<AbstractUtf8Array, Boolean> createPayload(ConfigKey<?> configKey, ConfigDefinition def) {
