Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jun 14, 2023
1 parent aa20281 commit c30f6aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public Collection<InjectedElement> getInjectedElements() {
* @since 6.0.10
*/
public Collection<InjectedElement> getInjectedElements(@Nullable PropertyValues pvs) {
return this.injectedElements.stream()
.filter(candidate -> candidate.shouldInject(pvs)).toList();
return this.injectedElements.stream().filter(candidate -> candidate.shouldInject(pvs)).toList();
}

/**
Expand All @@ -117,7 +116,7 @@ public Collection<InjectedElement> getInjectedElements(@Nullable PropertyValues
* @since 5.2.4
*/
protected boolean needsRefresh(Class<?> clazz) {
return this.targetClass != clazz;
return (this.targetClass != clazz);
}

public void checkConfigMembers(RootBeanDefinition beanDefinition) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -27,7 +27,9 @@

/**
* 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.
*
* <p>This context also extends {@link RequestReplyReceiverContext} for propagating
* tracing information during HTTP request processing.
*
Expand All @@ -43,13 +45,23 @@ public class ServerRequestObservationContext extends RequestReplyReceiverContext

private boolean connectionAborted;

public ServerRequestObservationContext(ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> 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<String, Object> 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.
*/
Expand Down Expand Up @@ -78,8 +90,8 @@ public void setPathPattern(@Nullable String pathPattern) {
}

/**
* 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
*/
Expand All @@ -88,8 +100,8 @@ public boolean isConnectionAborted() {
}

/**
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,10 @@ default <T> T getAttributeOrDefault(String name, T defaultValue) {
*/
default Mono<Void> 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();
}

Expand Down

0 comments on commit c30f6aa

Please sign in to comment.