From 65154170d39cd4cb53c65e062b1c8e54ca0019f9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 6 Jun 2020 18:49:32 +0200 Subject: [PATCH] Polishing --- .../main/java/org/springframework/http/RequestEntity.java | 4 +++- .../java/org/springframework/http/ResponseEntity.java | 4 ++++ .../web/reactive/function/client/DefaultWebClient.java | 5 +---- .../reactive/function/client/DefaultWebClientBuilder.java | 8 ++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/RequestEntity.java b/spring-web/src/main/java/org/springframework/http/RequestEntity.java index 19133210db..34255c4d5c 100644 --- a/spring-web/src/main/java/org/springframework/http/RequestEntity.java +++ b/spring-web/src/main/java/org/springframework/http/RequestEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -70,6 +70,8 @@ import org.springframework.util.ObjectUtils; * @param the body type * @see #getMethod() * @see #getUrl() + * @see org.springframework.web.client.RestOperations#exchange(RequestEntity, Class) + * @see ResponseEntity */ public class RequestEntity extends HttpEntity { diff --git a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java index f9df9eb3a1..591b56606f 100644 --- a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java +++ b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java @@ -70,6 +70,10 @@ import org.springframework.util.ObjectUtils; * @since 3.0.2 * @param the body type * @see #getStatusCode() + * @see org.springframework.web.client.RestOperations#getForEntity(String, Class, Object...) + * @see org.springframework.web.client.RestOperations#getForEntity(String, Class, java.util.Map) + * @see org.springframework.web.client.RestOperations#getForEntity(URI, Class) + * @see RequestEntity */ public class ResponseEntity extends HttpEntity { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java index 4803d3811a..9657d5def5 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java @@ -417,26 +417,23 @@ class DefaultWebClient implements WebClient { private static class DefaultResponseSpec implements ResponseSpec { - private static final IntPredicate STATUS_CODE_ERROR = value -> value >= 400; + private static final IntPredicate STATUS_CODE_ERROR = (value -> value >= 400); private static final StatusHandler DEFAULT_STATUS_HANDLER = new StatusHandler(STATUS_CODE_ERROR, ClientResponse::createException); - private final Mono responseMono; private final Supplier requestSupplier; private final List statusHandlers = new ArrayList<>(1); - DefaultResponseSpec(Mono responseMono, Supplier requestSupplier) { this.responseMono = responseMono; this.requestSupplier = requestSupplier; this.statusHandlers.add(DEFAULT_STATUS_HANDLER); } - @Override public ResponseSpec onStatus(Predicate statusPredicate, Function> exceptionFunction) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index 8ed5069ad7..3b52090258 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -101,6 +101,7 @@ final class DefaultWebClientBuilder implements WebClient.Builder { this.defaultUriVariables = (other.defaultUriVariables != null ? new LinkedHashMap<>(other.defaultUriVariables) : null); this.uriBuilderFactory = other.uriBuilderFactory; + if (other.defaultHeaders != null) { this.defaultHeaders = new HttpHeaders(); this.defaultHeaders.putAll(other.defaultHeaders); @@ -108,13 +109,16 @@ final class DefaultWebClientBuilder implements WebClient.Builder { else { this.defaultHeaders = null; } + this.defaultCookies = (other.defaultCookies != null ? new LinkedMultiValueMap<>(other.defaultCookies) : null); this.defaultRequest = other.defaultRequest; - this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; + this.filters = (other.filters != null ? new ArrayList<>(other.filters) : null); + this.connector = other.connector; this.strategies = other.strategies; - this.strategiesConfigurers = other.strategiesConfigurers != null ? new ArrayList<>(other.strategiesConfigurers) : null; + this.strategiesConfigurers = (other.strategiesConfigurers != null ? + new ArrayList<>(other.strategiesConfigurers) : null); this.exchangeFunction = other.exchangeFunction; }