From c30f6aa42799fda498cc29081bb9e1dd6c82af8f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 14 Jun 2023 22:17:39 +0200 Subject: [PATCH] Polishing --- .../factory/annotation/InjectionMetadata.java | 5 ++-- .../ServerRequestObservationContext.java | 26 ++++++++++++++----- .../web/server/ServerWebExchange.java | 5 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java index 0cd614f36c3..590c2152f5b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java @@ -106,8 +106,7 @@ public class InjectionMetadata { * @since 6.0.10 */ public Collection getInjectedElements(@Nullable PropertyValues pvs) { - return this.injectedElements.stream() - .filter(candidate -> candidate.shouldInject(pvs)).toList(); + return this.injectedElements.stream().filter(candidate -> candidate.shouldInject(pvs)).toList(); } /** @@ -117,7 +116,7 @@ public class InjectionMetadata { * @since 5.2.4 */ protected boolean needsRefresh(Class clazz) { - return this.targetClass != clazz; + return (this.targetClass != clazz); } public void checkConfigMembers(RootBeanDefinition beanDefinition) { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/observation/ServerRequestObservationContext.java b/spring-web/src/main/java/org/springframework/http/server/reactive/observation/ServerRequestObservationContext.java index 070d8637345..df9aa4ce46a 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/observation/ServerRequestObservationContext.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/observation/ServerRequestObservationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -27,7 +27,9 @@ import org.springframework.lang.Nullable; /** * Context that holds information for metadata collection regarding - * {@link ServerHttpObservationDocumentation#HTTP_REACTIVE_SERVER_REQUESTS reactive HTTP requests} observations. + * {@link ServerHttpObservationDocumentation#HTTP_REACTIVE_SERVER_REQUESTS reactive HTTP requests} + * observations. + * *

This context also extends {@link RequestReplyReceiverContext} for propagating * tracing information during HTTP request processing. * @@ -43,13 +45,23 @@ public class ServerRequestObservationContext extends RequestReplyReceiverContext private boolean connectionAborted; - public ServerRequestObservationContext(ServerHttpRequest request, ServerHttpResponse response, Map attributes) { + + /** + * Create a new {@code ServerRequestObservationContext} instance. + * @param request the current request + * @param response the current response + * @param attributes the current attributes + */ + public ServerRequestObservationContext( + ServerHttpRequest request, ServerHttpResponse response, Map attributes) { + super((req, key) -> req.getHeaders().getFirst(key)); setCarrier(request); setResponse(response); this.attributes = Collections.unmodifiableMap(attributes); } + /** * Return an immutable map of the current request attributes. */ @@ -78,8 +90,8 @@ public class ServerRequestObservationContext extends RequestReplyReceiverContext } /** - * Whether the current connection was aborted by the client, resulting - * in a {@link reactor.core.publisher.SignalType#CANCEL cancel signal} on the reactive chain, + * Whether the current connection was aborted by the client, resulting in a + * {@link reactor.core.publisher.SignalType#CANCEL cancel signal} on the reactive chain, * or an {@code AbortedException} when reading the request. * @return if the connection has been aborted */ @@ -88,8 +100,8 @@ public class ServerRequestObservationContext extends RequestReplyReceiverContext } /** - * Set whether the current connection was aborted by the client, resulting - * in a {@link reactor.core.publisher.SignalType#CANCEL cancel signal} on the reactive chain, + * Set whether the current connection was aborted by the client, resulting in a + * {@link reactor.core.publisher.SignalType#CANCEL cancel signal} on the reactive chain, * or an {@code AbortedException} when reading the request. * @param connectionAborted if the connection has been aborted */ diff --git a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java index c1f758c7e77..56c5cef3a62 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java +++ b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java @@ -148,11 +148,10 @@ public interface ServerWebExchange { */ default Mono cleanupMultipart() { return getMultipartData() - .onErrorResume(t -> Mono.empty()) // ignore errors reading multipart data + .onErrorResume(t -> Mono.empty()) // ignore errors reading multipart data .flatMapIterable(Map::values) .flatMapIterable(Function.identity()) - .flatMap(part -> part.delete() - .onErrorResume(ex -> Mono.empty())) + .flatMap(part -> part.delete().onErrorResume(ex -> Mono.empty())) .then(); }