Skip to content

Commit 24d1474

Browse files
committed
Revert "Adapt to framework change that makes CacheControl immutable"
This reverts commit 7343254 as the change in Framework has been reverted as well.
1 parent a839cbd commit 24d1474

File tree

1 file changed

+12
-24
lines changed
  • spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web

1 file changed

+12
-24
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -569,32 +569,20 @@ public void setSMaxAge(Duration sMaxAge) {
569569
public CacheControl toHttpCacheControl() {
570570
PropertyMapper map = PropertyMapper.get();
571571
CacheControl control = createCacheControl();
572-
if (Boolean.TRUE.equals(this.mustRevalidate)) {
573-
control = control.mustRevalidate();
574-
}
575-
if (Boolean.TRUE.equals(this.noTransform)) {
576-
control = control.noTransform();
577-
}
578-
if (Boolean.TRUE.equals(this.cachePrivate)) {
579-
control = control.cachePrivate();
580-
}
581-
if (Boolean.TRUE.equals(this.cachePublic)) {
582-
control = control.cachePublic();
583-
}
584-
if (Boolean.TRUE.equals(this.proxyRevalidate)) {
585-
control = control.proxyRevalidate();
586-
}
587-
control = map.from(this::getStaleWhileRevalidate)
572+
map.from(this::getMustRevalidate).whenTrue().toCall(control::mustRevalidate);
573+
map.from(this::getNoTransform).whenTrue().toCall(control::noTransform);
574+
map.from(this::getCachePublic).whenTrue().toCall(control::cachePublic);
575+
map.from(this::getCachePrivate).whenTrue().toCall(control::cachePrivate);
576+
map.from(this::getProxyRevalidate).whenTrue().toCall(control::proxyRevalidate);
577+
map.from(this::getStaleWhileRevalidate)
588578
.whenNonNull()
589-
.to(control, (instance, duration) -> instance.staleWhileRevalidate(duration.getSeconds(),
590-
TimeUnit.SECONDS));
591-
control = map.from(this::getStaleIfError)
579+
.to((duration) -> control.staleWhileRevalidate(duration.getSeconds(), TimeUnit.SECONDS));
580+
map.from(this::getStaleIfError)
592581
.whenNonNull()
593-
.to(control,
594-
(instance, duration) -> instance.staleIfError(duration.getSeconds(), TimeUnit.SECONDS));
595-
control = map.from(this::getSMaxAge)
582+
.to((duration) -> control.staleIfError(duration.getSeconds(), TimeUnit.SECONDS));
583+
map.from(this::getSMaxAge)
596584
.whenNonNull()
597-
.to(control, (instance, duration) -> instance.sMaxAge(duration.getSeconds(), TimeUnit.SECONDS));
585+
.to((duration) -> control.sMaxAge(duration.getSeconds(), TimeUnit.SECONDS));
598586
// check if cacheControl remained untouched
599587
if (control.getHeaderValue() == null) {
600588
return null;

0 commit comments

Comments
 (0)