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
6c6ce722
Commit
6c6ce722
authored
Sep 19, 2017
by
Vedran Pavic
Committed by
Stephane Nicoll
Sep 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove usage of `HttpStatus` in Web Endpoints
See gh-10350
parent
326290b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
11 deletions
+40
-11
AuditEventsWebEndpointExtension.java
...k/boot/actuate/audit/AuditEventsWebEndpointExtension.java
+1
-2
WebEndpointResponse.java
...mework/boot/actuate/endpoint/web/WebEndpointResponse.java
+27
-1
HealthStatusHttpMapper.java
...framework/boot/actuate/health/HealthStatusHttpMapper.java
+7
-4
HeapDumpWebEndpoint.java
...ramework/boot/actuate/management/HeapDumpWebEndpoint.java
+5
-4
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsWebEndpointExtension.java
View file @
6c6ce722
...
...
@@ -22,7 +22,6 @@ import org.springframework.boot.actuate.audit.AuditEventsEndpoint.AuditEventsDes
import
org.springframework.boot.actuate.endpoint.annotation.ReadOperation
;
import
org.springframework.boot.actuate.endpoint.web.WebEndpointResponse
;
import
org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointExtension
;
import
org.springframework.http.HttpStatus
;
/**
* {@link WebEndpointExtension} for the {@link AuditEventsEndpoint}.
...
...
@@ -43,7 +42,7 @@ public class AuditEventsWebEndpointExtension {
public
WebEndpointResponse
<
AuditEventsDescriptor
>
eventsWithPrincipalDateAfterAndType
(
String
principal
,
Date
after
,
String
type
)
{
if
(
after
==
null
)
{
return
new
WebEndpointResponse
<>(
HttpStatus
.
BAD_REQUEST
.
value
()
);
return
new
WebEndpointResponse
<>(
WebEndpointResponse
.
BAD_REQUEST_STATUS
);
}
AuditEventsDescriptor
auditEvents
=
this
.
delegate
.
eventsWithPrincipalDateAfterAndType
(
principal
,
after
,
type
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebEndpointResponse.java
View file @
6c6ce722
...
...
@@ -26,10 +26,36 @@ import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointExten
* @param <T> the type of the response body
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Vedran Pavic
* @since 2.0.0
*/
public
final
class
WebEndpointResponse
<
T
>
{
/**
* {@code 200 OK}.
*/
public
static
final
int
OK_STATUS
=
200
;
/**
* {@code 400 Bad Request}.
*/
public
static
final
int
BAD_REQUEST_STATUS
=
400
;
/**
* {@code 429 Too Many Requests}.
*/
public
static
final
int
TOO_MANY_REQUESTS_STATUS
=
429
;
/**
* {@code 500 Internal Server Error}.
*/
public
static
final
int
INTERNAL_SERVER_ERROR_STATUS
=
500
;
/**
* {@code 503 Service Unavailable}.
*/
public
static
final
int
SERVICE_UNAVAILABLE_STATUS
=
503
;
private
final
T
body
;
private
final
int
status
;
...
...
@@ -56,7 +82,7 @@ public final class WebEndpointResponse<T> {
* @param body the body
*/
public
WebEndpointResponse
(
T
body
)
{
this
(
body
,
200
);
this
(
body
,
OK_STATUS
);
}
/**
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthStatusHttpMapper.java
View file @
6c6ce722
...
...
@@ -20,6 +20,7 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.boot.actuate.endpoint.web.WebEndpointResponse
;
import
org.springframework.util.Assert
;
/**
...
...
@@ -40,8 +41,9 @@ public class HealthStatusHttpMapper {
}
private
void
setupDefaultStatusMapping
()
{
addStatusMapping
(
Status
.
DOWN
,
503
);
addStatusMapping
(
Status
.
OUT_OF_SERVICE
,
503
);
addStatusMapping
(
Status
.
DOWN
,
WebEndpointResponse
.
SERVICE_UNAVAILABLE_STATUS
);
addStatusMapping
(
Status
.
OUT_OF_SERVICE
,
WebEndpointResponse
.
SERVICE_UNAVAILABLE_STATUS
);
}
/**
...
...
@@ -102,9 +104,10 @@ public class HealthStatusHttpMapper {
if
(
code
!=
null
)
{
return
this
.
statusMapping
.
keySet
().
stream
()
.
filter
((
key
)
->
code
.
equals
(
getUniformValue
(
key
)))
.
map
(
this
.
statusMapping
::
get
).
findFirst
().
orElse
(
200
);
.
map
(
this
.
statusMapping
::
get
).
findFirst
()
.
orElse
(
WebEndpointResponse
.
OK_STATUS
);
}
return
200
;
return
WebEndpointResponse
.
OK_STATUS
;
}
private
String
getUniformValue
(
String
code
)
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java
View file @
6c6ce722
...
...
@@ -42,7 +42,6 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import
org.springframework.boot.actuate.endpoint.web.WebEndpointResponse
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
...
...
@@ -89,12 +88,14 @@ public class HeapDumpWebEndpoint {
Thread
.
currentThread
().
interrupt
();
}
catch
(
IOException
ex
)
{
return
new
WebEndpointResponse
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
return
new
WebEndpointResponse
<>(
WebEndpointResponse
.
INTERNAL_SERVER_ERROR_STATUS
);
}
catch
(
HeapDumperUnavailableException
ex
)
{
return
new
WebEndpointResponse
<>(
HttpStatus
.
SERVICE_UNAVAILABLE
.
value
());
return
new
WebEndpointResponse
<>(
WebEndpointResponse
.
SERVICE_UNAVAILABLE_STATUS
);
}
return
new
WebEndpointResponse
<>(
HttpStatus
.
TOO_MANY_REQUESTS
.
value
()
);
return
new
WebEndpointResponse
<>(
WebEndpointResponse
.
TOO_MANY_REQUESTS_STATUS
);
}
private
Resource
dumpHeap
(
boolean
live
)
throws
IOException
,
InterruptedException
{
...
...
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