Skip to content

Commit 818c2aa

Browse files
committed
ServerRequest.attribute(name) defensively accesses concurrent map
Issue: SPR-17486
1 parent d96a7b4 commit 818c2aa

File tree

1 file changed

+2
-8
lines changed
  • spring-webflux/src/main/java/org/springframework/web/reactive/function/server

1 file changed

+2
-8
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,7 @@ default PathContainer pathContainer() {
187187
* @return the attribute value
188188
*/
189189
default Optional<Object> attribute(String name) {
190-
Map<String, Object> attributes = attributes();
191-
if (attributes.containsKey(name)) {
192-
return Optional.of(attributes.get(name));
193-
}
194-
else {
195-
return Optional.empty();
196-
}
190+
return Optional.ofNullable(attributes().get(name));
197191
}
198192

199193
/**
@@ -350,7 +344,7 @@ interface Headers {
350344
Optional<MediaType> contentType();
351345

352346
/**
353-
* Get the value of the required {@code Host} header.
347+
* Get the value of the {@code Host} header, if available.
354348
* <p>If the header value does not contain a port, the
355349
* {@linkplain InetSocketAddress#getPort() port} in the returned address will
356350
* be {@code 0}.

0 commit comments

Comments
 (0)