Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
88b74097
Commit
88b74097
authored
Mar 24, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish 'Ignore quality value when removing MediaType.ALL'
See gh-25778
parent
3090a3a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+2
-2
DefaultErrorWebExceptionHandlerTests.java
.../reactive/error/DefaultErrorWebExceptionHandlerTests.java
+4
-5
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
88b74097
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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
<
MediaType
>
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
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java
View file @
88b74097
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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
Abstrac
tErrorWebExceptionHandler}.
* Tests for {@link
Defaul
tErrorWebExceptionHandler}.
*
* @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
<
HttpMessageReader
<?>>
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
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment