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;
import
org.springframework.util.AntPathMatcher
;
import
org.springframework.web.reactive.function.BodyInserter
;
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.server.ResponseStatusException
;
import
static
java
.
util
.
stream
.
Collectors
.
toMap
;
...
...
@@ -56,6 +56,7 @@ public class AbstractInstancesProxyController {
private
final
InstanceWebClient
instanceWebClient
;
private
final
Set
<
String
>
ignoredHeaders
;
private
final
Duration
readTimeout
;
private
final
ExchangeStrategies
strategies
=
ExchangeStrategies
.
withDefaults
();
public
AbstractInstancesProxyController
(
String
adminContextPath
,
Set
<
String
>
ignoredHeaders
,
...
...
@@ -80,7 +81,8 @@ public class AbstractInstancesProxyController {
return
registry
.
getInstance
(
InstanceId
.
of
(
instanceId
))
.
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
,
...
...
@@ -104,14 +106,14 @@ public class AbstractInstancesProxyController {
}
return
headersSpec
.
exchange
()
.
timeout
(
this
.
readTimeout
,
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
GATEWAY_TIMEOUT
).
build
()))
.
onError
Map
(
ResolveEndpointException
.
class
,
error
->
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
null
,
error
))
.
onErrorResume
(
IOException
.
class
,
ex
->
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
).
build
()))
.
onErrorResume
(
ConnectException
.
class
,
ex
->
Mono
.
just
(
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
).
build
()));
.
timeout
(
this
.
readTimeout
,
Mono
.
fromSupplier
(
()
->
ClientResponse
.
create
(
HttpStatus
.
GATEWAY_TIMEOUT
,
strategies
).
build
()))
.
onError
Resume
(
ResolveEndpointException
.
class
,
ex
->
Mono
.
fromSupplier
(
()
->
ClientResponse
.
create
(
HttpStatus
.
NOT_FOUND
,
strategies
).
build
()
))
.
onErrorResume
(
IOException
.
class
,
ex
->
Mono
.
fromSupplier
(
()
->
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
,
strategies
).
build
()))
.
onErrorResume
(
ConnectException
.
class
,
ex
->
Mono
.
fromSupplier
(
()
->
ClientResponse
.
create
(
HttpStatus
.
BAD_GATEWAY
,
strategies
).
build
()));
}
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