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
f7618cb4
Commit
f7618cb4
authored
Nov 03, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
f32f3ed4
bdfceae2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
MetricsFilter.java
...ngframework/boot/actuate/autoconfigure/MetricsFilter.java
+3
-0
MetricFilterAutoConfigurationTests.java
...ate/autoconfigure/MetricFilterAutoConfigurationTests.java
+31
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricsFilter.java
View file @
f7618cb4
...
...
@@ -109,6 +109,9 @@ final class MetricsFilter extends OncePerRequestFilter {
}
finally
{
if
(!
request
.
isAsyncStarted
())
{
if
(
response
.
isCommitted
())
{
status
=
getStatus
(
response
);
}
stopWatch
.
stop
();
request
.
removeAttribute
(
ATTRIBUTE_STOP_WATCH
);
recordMetrics
(
request
,
path
,
status
,
stopWatch
.
getTotalTimeMillis
());
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfigurationTests.java
View file @
f7618cb4
...
...
@@ -365,6 +365,37 @@ public class MetricFilterAutoConfigurationTests {
context
.
close
();
}
@Test
public
void
whenExceptionIsThrownResponseStatusIsUsedWhenResponseHasBeenCommitted
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
register
(
Config
.
class
,
MetricFilterAutoConfiguration
.
class
);
context
.
refresh
();
Filter
filter
=
context
.
getBean
(
Filter
.
class
);
final
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"GET"
,
"/test/path"
);
final
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
FilterChain
chain
=
mock
(
FilterChain
.
class
);
willAnswer
(
new
Answer
<
Object
>()
{
@Override
public
Object
answer
(
InvocationOnMock
invocation
)
throws
Throwable
{
response
.
setStatus
(
200
);
response
.
setCommitted
(
true
);
throw
new
IOException
();
}
}).
given
(
chain
).
doFilter
(
request
,
response
);
try
{
filter
.
doFilter
(
request
,
response
,
chain
);
fail
();
}
catch
(
IOException
ex
)
{
// Continue
}
verify
(
context
.
getBean
(
CounterService
.
class
))
.
increment
(
eq
(
"status.200.test.path"
));
context
.
close
();
}
@Configuration
public
static
class
Config
{
...
...
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