diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index 8f97d45f70dd..bfc926a6e0c2 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -342,8 +342,7 @@ protected CacheOperationMetadata getCacheOperationMetadata( CacheOperation operation, Method method, Class targetClass) { CacheOperationCacheKey cacheKey = new CacheOperationCacheKey(operation, method, targetClass); - CacheOperationMetadata metadata = this.metadataCache.get(cacheKey); - if (metadata == null) { + return this.metadataCache.computeIfAbsent(cacheKey, ignored -> { KeyGenerator operationKeyGenerator; if (StringUtils.hasText(operation.getKeyGenerator())) { operationKeyGenerator = getBean(operation.getKeyGenerator(), KeyGenerator.class); @@ -363,11 +362,9 @@ else if (StringUtils.hasText(operation.getCacheManager())) { operationCacheResolver = getCacheResolver(); Assert.state(operationCacheResolver != null, "No CacheResolver/CacheManager set"); } - metadata = new CacheOperationMetadata(operation, method, targetClass, + return new CacheOperationMetadata(operation, method, targetClass, operationKeyGenerator, operationCacheResolver); - this.metadataCache.put(cacheKey, metadata); - } - return metadata; + }); } /** diff --git a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java index 54ec2a76e9aa..72cd9e979a5f 100644 --- a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java +++ b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -273,13 +273,11 @@ public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDe "Expected [" + this.annotationType.getName() + "] to be present on " + sourceType); } AnnotationConverterKey converterKey = new AnnotationConverterKey(ann, sourceType.getObjectType()); - GenericConverter converter = cachedPrinters.get(converterKey); - if (converter == null) { + GenericConverter converter = cachedPrinters.computeIfAbsent(converterKey, key -> { Printer printer = this.annotationFormatterFactory.getPrinter( - converterKey.getAnnotation(), converterKey.getFieldType()); - converter = new PrinterConverter(this.fieldType, printer, FormattingConversionService.this); - cachedPrinters.put(converterKey, converter); - } + key.getAnnotation(), key.getFieldType()); + return new PrinterConverter(this.fieldType, printer, FormattingConversionService.this); + }); return converter.convert(source, sourceType, targetType); } @@ -328,13 +326,11 @@ public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDe "Expected [" + this.annotationType.getName() + "] to be present on " + targetType); } AnnotationConverterKey converterKey = new AnnotationConverterKey(ann, targetType.getObjectType()); - GenericConverter converter = cachedParsers.get(converterKey); - if (converter == null) { + GenericConverter converter = cachedParsers.computeIfAbsent(converterKey, key -> { Parser parser = this.annotationFormatterFactory.getParser( - converterKey.getAnnotation(), converterKey.getFieldType()); - converter = new ParserConverter(this.fieldType, parser, FormattingConversionService.this); - cachedParsers.put(converterKey, converter); - } + key.getAnnotation(), key.getFieldType()); + return new ParserConverter(this.fieldType, parser, FormattingConversionService.this); + }); return converter.convert(source, sourceType, targetType); } diff --git a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java index 063993eb0983..25300cc25ff6 100644 --- a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java +++ b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java @@ -534,11 +534,7 @@ private Object invokeOperation(Method method, Object[] args) throws JMException, String[] signature; synchronized (this.signatureCache) { - signature = this.signatureCache.get(method); - if (signature == null) { - signature = JmxUtils.getMethodSignature(method); - this.signatureCache.put(method, signature); - } + signature = this.signatureCache.computeIfAbsent(method, JmxUtils::getMethodSignature); } return this.serverToUse.invoke(this.objectName, method.getName(), args, signature); diff --git a/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java b/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java index f93bdf7e4da8..2dde4b0ca2e7 100644 --- a/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java +++ b/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -143,17 +143,16 @@ public Theme getTheme(String themeName) { Theme theme = this.themeCache.get(themeName); if (theme == null) { synchronized (this.themeCache) { - theme = this.themeCache.get(themeName); - if (theme == null) { - String basename = this.basenamePrefix + themeName; + theme = this.themeCache.computeIfAbsent(themeName, key -> { + String basename = this.basenamePrefix + key; MessageSource messageSource = createMessageSource(basename); - theme = new SimpleTheme(themeName, messageSource); - initParent(theme); - this.themeCache.put(themeName, theme); + Theme themeToUse = new SimpleTheme(key, messageSource); + initParent(themeToUse); if (logger.isDebugEnabled()) { - logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]"); + logger.debug("Theme created: name '" + key + "', basename [" + basename + "]"); } - } + return themeToUse; + }); } } return theme; diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java index 6c24dc7828bb..6c99468da5cf 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; +import org.springframework.util.function.ThrowingFunction; /** * {@link SingleConnectionFactory} subclass that adds {@link Session} caching as well as @@ -428,19 +429,13 @@ else if (isCacheConsumers()) { private MessageProducer getCachedProducer(@Nullable Destination dest) throws JMSException { DestinationCacheKey cacheKey = (dest != null ? new DestinationCacheKey(dest) : null); - MessageProducer producer = this.cachedProducers.get(cacheKey); - if (producer != null) { - if (logger.isTraceEnabled()) { - logger.trace("Found cached JMS MessageProducer for destination [" + dest + "]: " + producer); - } - } - else { - producer = this.target.createProducer(dest); + MessageProducer producer = this.cachedProducers.computeIfAbsent(cacheKey, (ThrowingFunction) ignored -> { + MessageProducer producerToUse = this.target.createProducer(dest); if (logger.isDebugEnabled()) { - logger.debug("Registering cached JMS MessageProducer for destination [" + dest + "]: " + producer); + logger.debug("Registering cached JMS MessageProducer for destination [" + dest + "]: " + producerToUse); } - this.cachedProducers.put(cacheKey, producer); - } + return producerToUse; + }); return new CachedMessageProducer(producer); } @@ -449,33 +444,28 @@ private MessageConsumer getCachedConsumer(Destination dest, @Nullable String sel @Nullable Boolean noLocal, @Nullable String subscription, boolean durable) throws JMSException { ConsumerCacheKey cacheKey = new ConsumerCacheKey(dest, selector, noLocal, subscription, durable); - MessageConsumer consumer = this.cachedConsumers.get(cacheKey); - if (consumer != null) { - if (logger.isTraceEnabled()) { - logger.trace("Found cached JMS MessageConsumer for destination [" + dest + "]: " + consumer); - } - } - else { + MessageConsumer consumer = this.cachedConsumers.computeIfAbsent(cacheKey, (ThrowingFunction) ignored -> { + MessageConsumer consumerToUse; if (dest instanceof Topic topic) { if (noLocal == null) { - consumer = (durable ? + consumerToUse = (durable ? this.target.createSharedDurableConsumer(topic, subscription, selector) : this.target.createSharedConsumer(topic, subscription, selector)); } else { - consumer = (durable ? + consumerToUse = (durable ? this.target.createDurableSubscriber(topic, subscription, selector, noLocal) : this.target.createConsumer(dest, selector, noLocal)); } } else { - consumer = this.target.createConsumer(dest, selector); + consumerToUse = this.target.createConsumer(dest, selector); } if (logger.isDebugEnabled()) { - logger.debug("Registering cached JMS MessageConsumer for destination [" + dest + "]: " + consumer); + logger.debug("Registering cached JMS MessageConsumer for destination [" + dest + "]: " + consumerToUse); } - this.cachedConsumers.put(cacheKey, consumer); - } + return consumerToUse; + }); return new CachedMessageConsumer(consumer); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java b/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java index bf83792123f8..2fc25b860698 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,13 +86,10 @@ public void afterPropertiesSet() { */ @Override public D resolveDestination(String name) throws DestinationResolutionException { - D destination = this.resolvedDestinationCache.get(name); - if (destination == null) { + return this.resolvedDestinationCache.computeIfAbsent(name, key -> { Assert.state(this.targetDestinationResolver != null, "No target DestinationResolver set"); - destination = this.targetDestinationResolver.resolveDestination(name); - this.resolvedDestinationCache.put(name, destination); - } - return destination; + return this.targetDestinationResolver.resolveDestination(key); + }); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/AbstractNamedValueMethodArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/AbstractNamedValueMethodArgumentResolver.java index 1a169e7294d9..f223d399dce4 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/AbstractNamedValueMethodArgumentResolver.java @@ -126,13 +126,7 @@ else if (namedValueInfo.required && !nestedParameter.isOptional()) { * Obtain the named value for the given method parameter. */ private NamedValueInfo getNamedValueInfo(MethodParameter parameter) { - NamedValueInfo namedValueInfo = this.namedValueInfoCache.get(parameter); - if (namedValueInfo == null) { - namedValueInfo = createNamedValueInfo(parameter); - namedValueInfo = updateNamedValueInfo(parameter, namedValueInfo); - this.namedValueInfoCache.put(parameter, namedValueInfo); - } - return namedValueInfo; + return this.namedValueInfoCache.computeIfAbsent(parameter, key -> updateNamedValueInfo(key, createNamedValueInfo(key))); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java index fd17f5e1f7ec..0310101f051c 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java @@ -136,13 +136,7 @@ else if (namedValueInfo.required && !nestedParameter.isOptional()) { * Obtain the named value for the given method parameter. */ private NamedValueInfo getNamedValueInfo(MethodParameter parameter) { - NamedValueInfo namedValueInfo = this.namedValueInfoCache.get(parameter); - if (namedValueInfo == null) { - namedValueInfo = createNamedValueInfo(parameter); - namedValueInfo = updateNamedValueInfo(parameter, namedValueInfo); - this.namedValueInfoCache.put(parameter, namedValueInfo); - } - return namedValueInfo; + return this.namedValueInfoCache.computeIfAbsent(parameter, key -> updateNamedValueInfo(key, createNamedValueInfo(key))); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java index 1c5b1593c847..331e9df3ab47 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,11 +120,7 @@ public Method resolveMethod(Throwable exception) { */ @Nullable public Method resolveMethodByExceptionType(Class exceptionType) { - Method method = this.exceptionLookupCache.get(exceptionType); - if (method == null) { - method = getMappedMethod(exceptionType); - this.exceptionLookupCache.put(exceptionType, method); - } + Method method = this.exceptionLookupCache.computeIfAbsent(exceptionType, this::getMappedMethod); return (method != NO_MATCHING_EXCEPTION_HANDLER_METHOD ? method : null); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java index e39b235f918f..be04701f3830 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -634,11 +634,7 @@ protected InvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handler logger.debug("Searching methods to handle " + exception.getClass().getSimpleName()); } Class beanType = handlerMethod.getBeanType(); - AbstractExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(beanType); - if (resolver == null) { - resolver = createExceptionHandlerMethodResolverFor(beanType); - this.exceptionHandlerCache.put(beanType, resolver); - } + AbstractExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.computeIfAbsent(beanType, this::createExceptionHandlerMethodResolverFor); Method method = resolver.resolveMethod(exception); if (method != null) { return new InvocableHandlerMethod(handlerMethod.getBean(), method); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java index ccb9c3c198b3..7738dd8c233a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHelper.java @@ -152,11 +152,7 @@ public InvocableHandlerMethod initExceptionHandlerMethod(HandlerMethod handlerMe logger.debug("Searching for methods to handle " + ex.getClass().getSimpleName()); } Class beanType = handlerMethod.getBeanType(); - AbstractExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(beanType); - if (resolver == null) { - resolver = this.exceptionMethodResolverFactory.apply(beanType); - this.exceptionHandlerCache.put(beanType, resolver); - } + AbstractExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.computeIfAbsent(beanType, this.exceptionMethodResolverFactory); InvocableHandlerMethod exceptionHandlerMethod = null; Method method = resolver.resolveMethod(ex); if (method != null) { diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java index f4c0b4149f74..fc59c81898db 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,11 +101,7 @@ public ContainedBean getBean( SpringContainedBean bean; if (lifecycleOptions.canUseCachedReferences()) { - bean = this.beanCache.get(beanType); - if (bean == null) { - bean = createBean(beanType, lifecycleOptions, fallbackProducer); - this.beanCache.put(beanType, bean); - } + bean = this.beanCache.computeIfAbsent(beanType, ignored -> createBean(beanType, lifecycleOptions, fallbackProducer)); } else { bean = createBean(beanType, lifecycleOptions, fallbackProducer); @@ -120,11 +116,7 @@ public ContainedBean getBean( SpringContainedBean bean; if (lifecycleOptions.canUseCachedReferences()) { - bean = this.beanCache.get(name); - if (bean == null) { - bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); - this.beanCache.put(name, bean); - } + bean = this.beanCache.computeIfAbsent(name, ignored -> createBean(name, beanType, lifecycleOptions, fallbackProducer)); } else { bean = createBean(name, beanType, lifecycleOptions, fallbackProducer); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java index 145d108f0ae5..9d37c8f5d580 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java @@ -155,13 +155,7 @@ else if (namedValueInfo.required && !nestedParameter.isOptional()) { * Obtain the named value for the given method parameter. */ private NamedValueInfo getNamedValueInfo(MethodParameter parameter) { - NamedValueInfo namedValueInfo = this.namedValueInfoCache.get(parameter); - if (namedValueInfo == null) { - namedValueInfo = createNamedValueInfo(parameter); - namedValueInfo = updateNamedValueInfo(parameter, namedValueInfo); - this.namedValueInfoCache.put(parameter, namedValueInfo); - } - return namedValueInfo; + return this.namedValueInfoCache.computeIfAbsent(parameter, key -> updateNamedValueInfo(key, createNamedValueInfo(key))); } /** diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java index 238a5e858626..6440ca5be404 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java @@ -103,16 +103,13 @@ public boolean resolve( @Nullable private NamedValueInfo getNamedValueInfo(MethodParameter parameter, HttpRequestValues.Metadata requestValues) { - NamedValueInfo info = this.namedValueInfoCache.get(parameter); - if (info == null) { - info = createNamedValueInfo(parameter, requestValues); - if (info == null) { + return this.namedValueInfoCache.computeIfAbsent(parameter, key -> { + NamedValueInfo infoToUse = createNamedValueInfo(key, requestValues); + if (infoToUse == null) { return null; } - info = updateNamedValueInfo(parameter, info); - this.namedValueInfoCache.put(parameter, info); - } - return info; + return updateNamedValueInfo(key, infoToUse); + }); } /** diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java index 25b177af66d2..773e2d3b7586 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java @@ -126,13 +126,7 @@ public Mono resolveArgument( * Obtain the named value for the given method parameter. */ private NamedValueInfo getNamedValueInfo(MethodParameter parameter) { - NamedValueInfo namedValueInfo = this.namedValueInfoCache.get(parameter); - if (namedValueInfo == null) { - namedValueInfo = createNamedValueInfo(parameter); - namedValueInfo = updateNamedValueInfo(parameter, namedValueInfo); - this.namedValueInfoCache.put(parameter, namedValueInfo); - } - return namedValueInfo; + return this.namedValueInfoCache.computeIfAbsent(parameter, key -> updateNamedValueInfo(key, createNamedValueInfo(key))); } /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java index 25ca3f0709c4..82034807a39f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java @@ -287,15 +287,12 @@ private HttpHeaders getHttpRequestHeaders(@Nullable HttpHeaders webSocketHttpHea private ServerInfo getServerInfo(SockJsUrlInfo sockJsUrlInfo, @Nullable HttpHeaders headers) { URI infoUrl = sockJsUrlInfo.getInfoUrl(); - ServerInfo info = this.serverInfoCache.get(infoUrl); - if (info == null) { + return this.serverInfoCache.computeIfAbsent(infoUrl, key -> { long start = System.currentTimeMillis(); - String response = this.infoReceiver.executeInfoRequest(infoUrl, headers); + String response = this.infoReceiver.executeInfoRequest(key, headers); long infoRequestTime = System.currentTimeMillis() - start; - info = new ServerInfo(response, infoRequestTime); - this.serverInfoCache.put(infoUrl, info); - } - return info; + return new ServerInfo(response, infoRequestTime); + }); } private DefaultTransportRequest createRequest(