Merge pull request #24386 from hyeonisism/Simplify-use-compute-if-absent
Closes gh-24386
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -821,18 +821,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* (never {@code null}).
|
||||
*/
|
||||
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
|
||||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType);
|
||||
if (sessionAttrHandler == null) {
|
||||
synchronized (this.sessionAttributesHandlerCache) {
|
||||
sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType);
|
||||
if (sessionAttrHandler == null) {
|
||||
sessionAttrHandler = new SessionAttributesHandler(handlerType, this.sessionAttributeStore);
|
||||
this.sessionAttributesHandlerCache.put(handlerType, sessionAttrHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sessionAttrHandler;
|
||||
return this.sessionAttributesHandlerCache.computeIfAbsent(
|
||||
handlerMethod.getBeanType(),
|
||||
type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user