Put CacheControl.empty() in else part.

Make sure the constructor of `CacheControl` being invoked only once.
This commit is contained in:
nkjackzhang 2018-04-20 18:18:18 +08:00 committed by Juergen Hoeller
parent 795e5d306c
commit 321d7b0b06
1 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -201,7 +201,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
private CacheControl parseCacheControl(Element element) {
CacheControl cacheControl = CacheControl.empty();
CacheControl cacheControl;
if ("true".equals(element.getAttribute("no-cache"))) {
cacheControl = CacheControl.noCache();
}
@ -211,6 +211,10 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
else if (element.hasAttribute("max-age")) {
cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS);
}
else {
cacheControl = CacheControl.empty();
}
if ("true".equals(element.getAttribute("must-revalidate"))) {
cacheControl = cacheControl.mustRevalidate();
}