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
620208a8
Commit
620208a8
authored
Mar 16, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
f80db03e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
33 deletions
+25
-33
ErrorProperties.java
...ringframework/boot/autoconfigure/web/ErrorProperties.java
+3
-1
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+4
-4
CouchbaseAutoConfigurationTests.java
...oconfigure/couchbase/CouchbaseAutoConfigurationTests.java
+1
-1
DefaultErrorWebExceptionHandlerIntegrationTests.java
...rror/DefaultErrorWebExceptionHandlerIntegrationTests.java
+16
-26
SpringConfigurationPropertySourcesTests.java
...rties/source/SpringConfigurationPropertySourcesTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java
View file @
620208a8
...
@@ -103,7 +103,8 @@ public class ErrorProperties {
...
@@ -103,7 +103,8 @@ public class ErrorProperties {
public
static
class
Whitelabel
{
public
static
class
Whitelabel
{
/**
/**
* Whether to enable the default error page displayed in browsers in case of a server error.
* Whether to enable the default error page displayed in browsers in case of a
* server error.
*/
*/
private
boolean
enabled
=
true
;
private
boolean
enabled
=
true
;
...
@@ -114,6 +115,7 @@ public class ErrorProperties {
...
@@ -114,6 +115,7 @@ public class ErrorProperties {
public
void
setEnabled
(
boolean
enabled
)
{
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
this
.
enabled
=
enabled
;
}
}
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
620208a8
...
@@ -119,20 +119,20 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
...
@@ -119,20 +119,20 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
boolean
includeStackTrace
=
isIncludeStackTrace
(
request
,
MediaType
.
TEXT_HTML
);
boolean
includeStackTrace
=
isIncludeStackTrace
(
request
,
MediaType
.
TEXT_HTML
);
Map
<
String
,
Object
>
error
=
getErrorAttributes
(
request
,
includeStackTrace
);
Map
<
String
,
Object
>
error
=
getErrorAttributes
(
request
,
includeStackTrace
);
HttpStatus
errorStatus
=
getHttpStatus
(
error
);
HttpStatus
errorStatus
=
getHttpStatus
(
error
);
ServerResponse
.
BodyBuilder
response
=
ServerResponse
.
status
(
errorStatus
)
ServerResponse
.
BodyBuilder
response
Body
=
ServerResponse
.
status
(
errorStatus
)
.
contentType
(
MediaType
.
TEXT_HTML
);
.
contentType
(
MediaType
.
TEXT_HTML
);
Flux
<
ServerResponse
>
result
=
Flux
Flux
<
ServerResponse
>
result
=
Flux
.
just
(
"error/"
+
errorStatus
.
toString
(),
.
just
(
"error/"
+
errorStatus
.
toString
(),
"error/"
+
SERIES_VIEWS
.
get
(
errorStatus
.
series
()),
"error/error"
)
"error/"
+
SERIES_VIEWS
.
get
(
errorStatus
.
series
()),
"error/error"
)
.
flatMap
((
viewName
)
->
renderErrorView
(
viewName
,
response
,
error
));
.
flatMap
((
viewName
)
->
renderErrorView
(
viewName
,
response
Body
,
error
));
if
(
this
.
errorProperties
.
getWhitelabel
().
isEnabled
())
{
if
(
this
.
errorProperties
.
getWhitelabel
().
isEnabled
())
{
result
=
result
.
switchIfEmpty
(
renderDefaultErrorView
(
response
,
error
));
result
=
result
.
switchIfEmpty
(
renderDefaultErrorView
(
response
Body
,
error
));
}
}
else
{
else
{
Throwable
ex
=
getError
(
request
);
Throwable
ex
=
getError
(
request
);
result
=
result
.
switchIfEmpty
(
Mono
.
error
(
ex
));
result
=
result
.
switchIfEmpty
(
Mono
.
error
(
ex
));
}
}
return
result
.
next
().
doOnNext
((
resp
)
->
logError
(
request
,
errorStatus
));
return
result
.
next
().
doOnNext
((
resp
onse
)
->
logError
(
request
,
errorStatus
));
}
}
/**
/**
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
View file @
620208a8
...
@@ -53,7 +53,7 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -53,7 +53,7 @@ public class CouchbaseAutoConfigurationTests {
@Test
@Test
public
void
bootstrapHostsIsRequired
()
{
public
void
bootstrapHostsIsRequired
()
{
this
.
contextRunner
.
run
(
(
context
)
->
assertNoCouchbaseBeans
(
context
)
);
this
.
contextRunner
.
run
(
this
::
assertNoCouchbaseBeans
);
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
View file @
620208a8
...
@@ -95,10 +95,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -95,10 +95,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
this
.
contextRunner
.
run
((
context
)
->
{
this
.
contextRunner
.
run
((
context
)
->
{
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
.
build
();
.
build
();
client
.
get
().
uri
(
"/notFound"
).
exchange
()
client
.
get
().
uri
(
"/notFound"
).
exchange
().
expectStatus
().
isNotFound
()
.
expectStatus
().
isNotFound
()
.
expectBody
().
jsonPath
(
"status"
).
isEqualTo
(
"404"
).
jsonPath
(
"error"
)
.
expectBody
().
jsonPath
(
"status"
)
.
isEqualTo
(
"404"
).
jsonPath
(
"error"
)
.
isEqualTo
(
HttpStatus
.
NOT_FOUND
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
(
HttpStatus
.
NOT_FOUND
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
((
"/notFound"
)).
jsonPath
(
"exception"
).
doesNotExist
();
.
isEqualTo
((
"/notFound"
)).
jsonPath
(
"exception"
).
doesNotExist
();
});
});
...
@@ -125,10 +123,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -125,10 +123,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
.
build
();
.
build
();
client
.
post
().
uri
(
"/bind"
).
contentType
(
MediaType
.
APPLICATION_JSON
)
client
.
post
().
uri
(
"/bind"
).
contentType
(
MediaType
.
APPLICATION_JSON
)
.
syncBody
(
"{}"
).
exchange
()
.
syncBody
(
"{}"
).
exchange
().
expectStatus
().
isBadRequest
().
expectBody
()
.
expectStatus
().
isBadRequest
()
.
jsonPath
(
"status"
).
isEqualTo
(
"400"
).
jsonPath
(
"error"
)
.
expectBody
().
jsonPath
(
"status"
)
.
isEqualTo
(
"400"
).
jsonPath
(
"error"
)
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
((
"/bind"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
isEqualTo
((
"/bind"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
jsonPath
(
"errors"
).
isArray
().
jsonPath
(
"message"
).
isNotEmpty
();
.
jsonPath
(
"errors"
).
isArray
().
jsonPath
(
"message"
).
isNotEmpty
();
...
@@ -195,10 +191,9 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -195,10 +191,9 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
run
((
context
)
->
{
.
run
((
context
)
->
{
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
.
build
();
.
build
();
client
.
get
().
uri
(
"/badRequest"
).
exchange
()
client
.
get
().
uri
(
"/badRequest"
).
exchange
().
expectStatus
()
.
expectStatus
().
isBadRequest
()
.
isBadRequest
().
expectBody
().
jsonPath
(
"status"
)
.
expectBody
().
jsonPath
(
"status"
).
isEqualTo
(
"400"
)
.
isEqualTo
(
"400"
).
jsonPath
(
"error"
)
.
jsonPath
(
"error"
)
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
())
.
jsonPath
(
"exception"
)
.
jsonPath
(
"exception"
)
.
isEqualTo
(
ResponseStatusException
.
class
.
getName
());
.
isEqualTo
(
ResponseStatusException
.
class
.
getName
());
...
@@ -254,9 +249,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -254,9 +249,8 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
.
build
();
.
build
();
String
body
=
client
.
get
().
uri
(
"/notfound"
)
String
body
=
client
.
get
().
uri
(
"/notfound"
)
.
accept
(
MediaType
.
TEXT_HTML
).
exchange
()
.
accept
(
MediaType
.
TEXT_HTML
).
exchange
().
expectStatus
()
.
expectStatus
().
isNotFound
()
.
isNotFound
().
expectHeader
().
contentType
(
MediaType
.
TEXT_HTML
)
.
expectHeader
().
contentType
(
MediaType
.
TEXT_HTML
)
.
expectBody
(
String
.
class
).
returnResult
().
getResponseBody
();
.
expectBody
(
String
.
class
).
returnResult
().
getResponseBody
();
assertThat
(
body
).
contains
(
"Whitelabel Error Page"
)
assertThat
(
body
).
contains
(
"Whitelabel Error Page"
)
.
contains
(
"type=Not Found, status=404"
);
.
contains
(
"type=Not Found, status=404"
);
...
@@ -276,17 +270,13 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -276,17 +270,13 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
@Test
@Test
public
void
whilelabelDisabled
()
{
public
void
whilelabelDisabled
()
{
this
.
contextRunner
this
.
contextRunner
.
withPropertyValues
(
"server.error.whitelabel.enabled=false"
,
.
withPropertyValues
(
"server.error.whitelabel.enabled=false"
,
"spring.mustache.prefix=classpath:/unknown/"
).
run
((
context
)
->
{
"spring.mustache.prefix=classpath:/unknown/"
)
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
.
run
((
context
)
->
{
.
build
();
WebTestClient
client
=
WebTestClient
.
bindToApplicationContext
(
context
)
client
.
get
().
uri
(
"/notfound"
).
accept
(
MediaType
.
TEXT_HTML
).
exchange
()
.
build
();
.
expectStatus
().
isNotFound
().
expectBody
().
isEmpty
();
client
.
get
().
uri
(
"/notfound"
)
});
.
accept
(
MediaType
.
TEXT_HTML
).
exchange
()
.
expectStatus
().
isNotFound
()
.
expectBody
().
isEmpty
();
});
}
}
@Configuration
@Configuration
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySourcesTests.java
View file @
620208a8
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
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