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
23aa468d
Commit
23aa468d
authored
Apr 11, 2018
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish servlet.InstancesProxyController
parent
9146943a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
18 deletions
+16
-18
InstancesProxyController.java
...ot/admin/server/web/servlet/InstancesProxyController.java
+16
-18
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/servlet/InstancesProxyController.java
View file @
23aa468d
...
...
@@ -20,16 +20,17 @@ import de.codecentric.boot.admin.server.services.InstanceRegistry;
import
de.codecentric.boot.admin.server.web.AbstractInstancesProxyController
;
import
de.codecentric.boot.admin.server.web.AdminController
;
import
de.codecentric.boot.admin.server.web.client.InstanceWebClient
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.URI
;
import
java.time.Duration
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.core.io.buffer.DataBufferFactory
;
import
org.springframework.core.io.buffer.DataBufferUtils
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
...
...
@@ -52,7 +53,6 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
@AdminController
public
class
InstancesProxyController
extends
AbstractInstancesProxyController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
InstancesProxyController
.
class
);
private
final
DataBufferFactory
bufferFactory
=
new
DefaultDataBufferFactory
();
public
InstancesProxyController
(
String
adminContextPath
,
...
...
@@ -80,7 +80,7 @@ public class InstancesProxyController extends AbstractInstancesProxyController {
.
build
(
true
)
.
toUri
();
//We need to explicitly block until the headers are recieved.
//We need to explicitly block until the headers are recieved
and write them before the async dispatch
.
//otherwise the FrameworkServlet will add wrong Allow header for OPTIONS request
ClientResponse
clientResponse
=
super
.
forward
(
instanceId
,
uri
,
request
.
getMethod
(),
request
.
getHeaders
(),
()
->
BodyInserters
.
fromDataBuffers
(
...
...
@@ -88,24 +88,22 @@ public class InstancesProxyController extends AbstractInstancesProxyController {
response
.
setStatusCode
(
clientResponse
.
statusCode
());
response
.
getHeaders
().
addAll
(
filterHeaders
(
clientResponse
.
headers
().
asHttpHeaders
()));
response
.
flush
();
OutputStream
responseBody
=
response
.
getBody
();
return
clientResponse
.
body
(
BodyExtractors
.
toDataBuffers
()).
window
(
1
).
flatMap
(
body
->
{
try
{
return
DataBufferUtils
.
write
(
body
,
response
.
getBody
())
.
map
(
DataBufferUtils:
:
release
)
.
then
(
Mono
.
fromRunnable
(()
->
{
return
clientResponse
.
body
(
BodyExtractors
.
toDataBuffers
())
.
window
(
1
)
.
flatMap
(
body
->
writeAndFlush
(
body
,
responseBody
))
.
then
();
}
private
Mono
<
Void
>
writeAndFlush
(
Flux
<
DataBuffer
>
body
,
OutputStream
responseBody
)
{
return
DataBufferUtils
.
write
(
body
,
responseBody
).
map
(
DataBufferUtils:
:
release
).
then
(
Mono
.
create
(
sink
->
{
try
{
response
.
getBody
().
flush
();
responseBody
.
flush
();
sink
.
success
();
}
catch
(
IOException
ex
)
{
//It's most likely that the client has disconnected.
//We can't handle that properly so we're ignoring the exception
log
.
debug
(
"Error flushing the response"
,
ex
);
sink
.
error
(
ex
);
}
}));
}
catch
(
IOException
ex
)
{
return
Mono
.
error
(
ex
);
}
}).
then
();
}
}
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