Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
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-cloud-netflix
Commits
c5d95ca8
Commit
c5d95ca8
authored
Jun 08, 2017
by
Jin Zhang
Committed by
Spencer Gibb
Jun 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SendErrorFilter: put response code into RequestContext, keep consistent with normal cases (#2004)
parent
9e180b8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
SendErrorFilter.java
...work/cloud/netflix/zuul/filters/post/SendErrorFilter.java
+1
-0
SendErrorFilterTests.java
...cloud/netflix/zuul/filters/post/SendErrorFilterTests.java
+14
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendErrorFilter.java
View file @
c5d95ca8
...
@@ -87,6 +87,7 @@ public class SendErrorFilter extends ZuulFilter {
...
@@ -87,6 +87,7 @@ public class SendErrorFilter extends ZuulFilter {
if
(
dispatcher
!=
null
)
{
if
(
dispatcher
!=
null
)
{
ctx
.
set
(
SEND_ERROR_FILTER_RAN
,
true
);
ctx
.
set
(
SEND_ERROR_FILTER_RAN
,
true
);
if
(!
ctx
.
getResponse
().
isCommitted
())
{
if
(!
ctx
.
getResponse
().
isCommitted
())
{
ctx
.
setResponseStatusCode
(
exception
.
nStatusCode
);
dispatcher
.
forward
(
request
,
ctx
.
getResponse
());
dispatcher
.
forward
(
request
,
ctx
.
getResponse
());
}
}
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/post/SendErrorFilterTests.java
View file @
c5d95ca8
...
@@ -29,6 +29,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
...
@@ -29,6 +29,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
@@ -82,4 +83,17 @@ public class SendErrorFilterTests {
...
@@ -82,4 +83,17 @@ public class SendErrorFilterTests {
filter
.
run
();
filter
.
run
();
assertFalse
(
"shouldFilter returned true"
,
filter
.
shouldFilter
());
assertFalse
(
"shouldFilter returned true"
,
filter
.
shouldFilter
());
}
}
@Test
public
void
setResponseCode
()
{
SendErrorFilter
filter
=
createSendErrorFilter
(
new
MockHttpServletRequest
());
filter
.
run
();
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
int
resCode
=
ctx
.
getResponse
().
getStatus
();
int
ctxCode
=
ctx
.
getResponseStatusCode
();
assertEquals
(
"invalid response code: "
+
resCode
,
HttpStatus
.
NOT_FOUND
.
value
(),
resCode
);
assertEquals
(
"invalid response code in RequestContext: "
+
ctxCode
,
resCode
,
ctxCode
);
}
}
}
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