diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 7daa3e6a23..e5f7465fc7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1208,7 +1208,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } private boolean isRequired(DependencyDescriptor descriptor) { - return this.autowireCandidateResolver.isRequired(descriptor); + return getAutowireCandidateResolver().isRequired(descriptor); } private boolean indicatesMultipleBeans(Class type) { diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index f23400ed19..6511262b84 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1283,8 +1283,8 @@ public abstract class AnnotationUtils { * single-element Annotation, given an annotation instance. * @param annotation the annotation instance from which to retrieve the value * @return the attribute value, or {@code null} if not found unless the attribute - * value cannot be retrieved due to an {@link AnnotationConfigurationException}, in - * which case such an exception will be rethrown + * value cannot be retrieved due to an {@link AnnotationConfigurationException}, + * in which case such an exception will be rethrown * @see #getValue(Annotation, String) */ public static Object getValue(Annotation annotation) { @@ -1296,8 +1296,8 @@ public abstract class AnnotationUtils { * @param annotation the annotation instance from which to retrieve the value * @param attributeName the name of the attribute value to retrieve * @return the attribute value, or {@code null} if not found unless the attribute - * value cannot be retrieved due to an {@link AnnotationConfigurationException}, in - * which case such an exception will be rethrown + * value cannot be retrieved due to an {@link AnnotationConfigurationException}, + * in which case such an exception will be rethrown * @see #getValue(Annotation) * @see #rethrowAnnotationConfigurationException(Throwable) */ diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/CookieResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/CookieResultMatchers.java index 32df6ac00c..0adda19b2c 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/CookieResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/CookieResultMatchers.java @@ -20,6 +20,7 @@ import javax.servlet.http.Cookie; import org.hamcrest.Matcher; +import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultMatcher; import static org.hamcrest.MatcherAssert.*; @@ -50,8 +51,7 @@ public class CookieResultMatchers { */ public ResultMatcher value(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); - assertTrue("Response cookie '" + name + "' not found", cookie != null); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "'", cookie.getValue(), matcher); }; } @@ -61,8 +61,7 @@ public class CookieResultMatchers { */ public ResultMatcher value(final String name, final String expectedValue) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); - assertTrue("Response cookie '" + name + "' not found", cookie != null); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie", expectedValue, cookie.getValue()); }; } @@ -72,10 +71,7 @@ public class CookieResultMatchers { * max age is 0 (i.e. expired). */ public ResultMatcher exists(final String name) { - return result -> { - Cookie cookie = result.getResponse().getCookie(name); - assertTrue("No cookie with name '" + name + "'", cookie != null); - }; + return result -> getCookie(result, name); } /** @@ -94,8 +90,7 @@ public class CookieResultMatchers { */ public ResultMatcher maxAge(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); - assertTrue("No cookie with name '" + name + "'", cookie != null); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "' maxAge", cookie.getMaxAge(), matcher); }; } @@ -105,8 +100,7 @@ public class CookieResultMatchers { */ public ResultMatcher maxAge(final String name, final int maxAge) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); - assertTrue("No cookie with name: " + name, cookie != null); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' maxAge", maxAge, cookie.getMaxAge()); }; } @@ -116,14 +110,14 @@ public class CookieResultMatchers { */ public ResultMatcher path(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "' path", cookie.getPath(), matcher); }; } public ResultMatcher path(final String name, final String path) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' path", path, cookie.getPath()); }; } @@ -133,7 +127,7 @@ public class CookieResultMatchers { */ public ResultMatcher domain(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "' domain", cookie.getDomain(), matcher); }; } @@ -143,7 +137,7 @@ public class CookieResultMatchers { */ public ResultMatcher domain(final String name, final String domain) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' domain", domain, cookie.getDomain()); }; } @@ -153,7 +147,7 @@ public class CookieResultMatchers { */ public ResultMatcher comment(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "' comment", cookie.getComment(), matcher); }; } @@ -163,7 +157,7 @@ public class CookieResultMatchers { */ public ResultMatcher comment(final String name, final String comment) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' comment", comment, cookie.getComment()); }; } @@ -173,7 +167,7 @@ public class CookieResultMatchers { */ public ResultMatcher version(final String name, final Matcher matcher) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertThat("Response cookie '" + name + "' version", cookie.getVersion(), matcher); }; } @@ -183,7 +177,7 @@ public class CookieResultMatchers { */ public ResultMatcher version(final String name, final int version) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' version", version, cookie.getVersion()); }; } @@ -193,7 +187,7 @@ public class CookieResultMatchers { */ public ResultMatcher secure(final String name, final boolean secure) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' secure", secure, cookie.getSecure()); }; } @@ -204,9 +198,16 @@ public class CookieResultMatchers { */ public ResultMatcher httpOnly(final String name, final boolean httpOnly) { return result -> { - Cookie cookie = result.getResponse().getCookie(name); + Cookie cookie = getCookie(result, name); assertEquals("Response cookie '" + name + "' httpOnly", httpOnly, cookie.isHttpOnly()); }; } + + private static Cookie getCookie(MvcResult result, String name) { + Cookie cookie = result.getResponse().getCookie(name); + assertTrue("No cookie with name '" + name + "'", cookie != null); + return cookie; + } + } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/HandlerResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/HandlerResultMatchers.java index 15f366ebc2..3660281509 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/HandlerResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/HandlerResultMatchers.java @@ -93,7 +93,6 @@ public class HandlerResultMatchers { * mockMvc.perform(get("/")) * .andExpect(handler().methodCall(on(SimpleController.class).handle())); * - * * @param obj either the value returned from a "mock" controller invocation * or the "mock" controller itself after an invocation */ diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java index c08f7df83b..654da16add 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java @@ -66,12 +66,12 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter> partWriters; private Charset charset = DEFAULT_CHARSET; - private final DataBufferFactory bufferFactory = new DefaultDataBufferFactory(); - public MultipartHttpMessageWriter() { this.partWriters = Arrays.asList( @@ -84,13 +84,14 @@ public class MultipartHttpMessageWriter implements HttpMessageWriterBy default this is set to "UTF-8". */ public void setCharset(Charset charset) { - Assert.notNull(charset, "'charset' must not be null"); + Assert.notNull(charset, "Charset must not be null"); this.charset = charset; } @@ -126,11 +127,9 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter { - Flux body = Flux.fromIterable(map.entrySet()) .concatMap(entry -> encodePartValues(boundary, entry.getKey(), entry.getValue())) .concatWith(Mono.just(generateLastLine(boundary))); - return outputMessage.writeWith(body); }); } @@ -150,9 +149,7 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter Flux encodePart(byte[] boundary, String name, T value) { - - MultipartHttpOutputMessage outputMessage = - new MultipartHttpOutputMessage(this.bufferFactory, getCharset()); + MultipartHttpOutputMessage outputMessage = new MultipartHttpOutputMessage(this.bufferFactory, getCharset()); T body; if (value instanceof HttpEntity) { @@ -173,7 +170,7 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter partWriter.canWrite(bodyType, contentType)) .findFirst(); - if(!writer.isPresent()) { + if (!writer.isPresent()) { return Flux.error(new CodecException("No suitable writer found for part: " + name)); } @@ -182,17 +179,14 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter body; - public MultipartHttpOutputMessage(DataBufferFactory bufferFactory, Charset charset) { this.bufferFactory = bufferFactory; this.charset = charset; } - @Override public HttpHeaders getHeaders() { return (this.body != null ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); @@ -254,12 +246,12 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter> action) { - this.commited.set(true); + this.committed.set(true); } @Override public boolean isCommitted() { - return this.commited.get(); + return this.committed.get(); } @Override @@ -305,7 +297,6 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter