Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
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
openSource
spring-boot-admin
Commits
791fe642
Commit
791fe642
authored
Apr 25, 2018
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create error responses only when necessary and reuse the exchangeStrategies
..to gain more performance and reduce gc pressure fixes #713
parent
e25e24e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
AbstractInstancesProxyController.java
...ot/admin/server/web/AbstractInstancesProxyController.java
+12
-10
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/AbstractInstancesProxyController.java
View file @
791fe642
...
@@ -42,8 +42,8 @@ import org.springframework.http.client.reactive.ClientHttpRequest;
...
@@ -42,8 +42,8 @@ import org.springframework.http.client.reactive.ClientHttpRequest;
import
org.springframework.util.AntPathMatcher
;
import
org.springframework.util.AntPathMatcher
;
import
org.springframework.web.reactive.function.BodyInserter
;
import
org.springframework.web.reactive.function.BodyInserter
;
import
org.springframework.web.reactive.function.client.ClientResponse
;
import
org.springframework.web.reactive.function.client.ClientResponse
;
import
org.springframework.web.reactive.function.client.ExchangeStrategies
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
org.springframework.web.server.ResponseStatusException
;
import
static
java
.
util
.
stream
.
Collectors
.
toMap
;
import
static
java
.
util
.
stream
.
Collectors
.
toMap
;
...
@@ -56,6 +56,7 @@ public class AbstractInstancesProxyController {
...
@@ -56,6 +56,7 @@ public class AbstractInstancesProxyController {
private
final
InstanceWebClient
instanceWebClient
;
private
final
InstanceWebClient
instanceWebClient
;
private
final
Set
<
String
>
ignoredHeaders
;
private
final
Set
<
String
>
ignoredHeaders
;
private
final
Duration
readTimeout
;
private
final
Duration
readTimeout
;
private
final
ExchangeStrategies
strategies
=
ExchangeStrategies
.
withDefaults
();
public
AbstractInstancesProxyController
(
String
adminContextPath
,
public
AbstractInstancesProxyController
(
String
adminContextPath
,
Set
<
String
>
ignoredHeaders
,
Set
<
String
>
ignoredHeaders
,
...
@@ -80,7 +81,8 @@ public class AbstractInstancesProxyController {
...
@@ -80,7 +81,8 @@ public class AbstractInstancesProxyController {
return
registry
.
getInstance
(
InstanceId
.
of
(
instanceId
))
return
registry
.
getInstance
(
InstanceId
.
of
(
instanceId
))
.
flatMap
(
instance
->
forward
(
instance
,
uri
,
method
,
headers
,
bodyInserter
))
.
flatMap
(
instance
->
forward
(
instance
,
uri
,
method
,
headers
,
bodyInserter
))
.
defaultIfEmpty
(
ClientResponse
.
create
(
HttpStatus
.
SERVICE_UNAVAILABLE
).
build
());
.
switchIfEmpty
(
Mono
.
fromSupplier
(
()
->
ClientResponse
.
create
(
HttpStatus
.
SERVICE_UNAVAILABLE
,
strategies
).
build
()));
}
}
private
Mono
<
ClientResponse
>
forward
(
Instance
instance
,
private
Mono
<
ClientResponse
>
forward
(
Instance
instance
,
...
@@ -104,14 +106,14 @@ public class AbstractInstancesProxyController {
...
@@ -104,14 +106,14 @@ public class AbstractInstancesProxyController {
}
}
return
headersSpec
.
exchange
()
return
headersSpec
.
exchange
()
.
timeout
(
this
.
readTimeout
,
.
timeout
(
this
.
readTimeout
,
Mono
.
fromSupplier
(
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
GATEWAY_TIMEOUT
).
build
()))
()
->
ClientResponse
.
create
(
HttpStatus
.
GATEWAY_TIMEOUT
,
strategies
).
build
()))
.
onError
Map
(
ResolveEndpointException
.
class
,
.
onError
Resume
(
ResolveEndpointException
.
class
,
ex
->
Mono
.
fromSupplier
(
error
->
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
null
,
error
))
()
->
ClientResponse
.
create
(
HttpStatus
.
NOT_FOUND
,
strategies
).
build
()
))
.
onErrorResume
(
IOException
.
class
,
.
onErrorResume
(
IOException
.
class
,
ex
->
Mono
.
fromSupplier
(
ex
->
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
).
build
()))
()
->
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
,
strategies
).
build
()))
.
onErrorResume
(
ConnectException
.
class
,
.
onErrorResume
(
ConnectException
.
class
,
ex
->
Mono
.
fromSupplier
(
ex
->
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
).
build
()));
()
->
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
,
strategies
).
build
()));
}
}
protected
String
getEndpointLocalPath
(
String
pathWithinApplication
)
{
protected
String
getEndpointLocalPath
(
String
pathWithinApplication
)
{
...
...
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