diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java index cc5fb2f7df..604b1c5a69 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -237,7 +237,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa return (serverRequest) -> { try { List acceptedMediaTypes = serverRequest.headers().accept(); - acceptedMediaTypes.removeIf((mediaType) -> MediaType.ALL.equalsTypeAndSubtype(mediaType)); + acceptedMediaTypes.removeIf(MediaType.ALL::equalsTypeAndSubtype); MediaType.sortBySpecificityAndQuality(acceptedMediaTypes); return acceptedMediaTypes.stream().anyMatch(MediaType.TEXT_HTML::isCompatibleWith); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java index e52a29e919..ba7ff5dfee 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -46,7 +46,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; /** - * Tests for {@link AbstractErrorWebExceptionHandler}. + * Tests for {@link DefaultErrorWebExceptionHandler}. * * @author Phillip Webb * @author Madhura Bhave @@ -66,10 +66,10 @@ class DefaultErrorWebExceptionHandlerTests { @Test void nonStandardErrorStatusCodeShouldNotFail() { ErrorAttributes errorAttributes = mock(ErrorAttributes.class); + given(errorAttributes.getErrorAttributes(any(), any())).willReturn(getErrorAttributes()); ResourceProperties resourceProperties = new ResourceProperties(); ErrorProperties errorProperties = new ErrorProperties(); ApplicationContext context = new AnnotationConfigReactiveWebApplicationContext(); - given(errorAttributes.getErrorAttributes(any(), any())).willReturn(getErrorAttributes()); DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, context); setupViewResolver(exceptionHandler); @@ -103,8 +103,7 @@ class DefaultErrorWebExceptionHandlerTests { .from(MockServerHttpRequest.get("/test").accept(allWithQuality)); List> readers = ServerCodecConfigurer.create().getReaders(); ServerRequest request = ServerRequest.create(exchange, readers); - boolean accepts = exceptionHandler.acceptsTextHtml().test(request); - assertThat(accepts).isFalse(); + assertThat(exceptionHandler.acceptsTextHtml().test(request)).isFalse(); } }