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
70aa7887
Commit
70aa7887
authored
Mar 21, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x'
Closes gh-20600
parents
9766127f
8593270b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
WebFluxTags.java
...boot/actuate/metrics/web/reactive/server/WebFluxTags.java
+1
-1
WebMvcTags.java
...ramework/boot/actuate/metrics/web/servlet/WebMvcTags.java
+1
-1
WebMvcTagsTests.java
...rk/boot/actuate/endpoint/web/servlet/WebMvcTagsTests.java
+16
-2
WebFluxTagsTests.java
...actuate/metrics/web/reactive/server/WebFluxTagsTests.java
+19
-2
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java
View file @
70aa7887
...
...
@@ -107,7 +107,7 @@ public final class WebFluxTags {
PathPattern
pathPattern
=
exchange
.
getAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
);
if
(
pathPattern
!=
null
)
{
String
patternString
=
pathPattern
.
getPatternString
();
if
(
ignoreTrailingSlash
)
{
if
(
ignoreTrailingSlash
&&
patternString
.
length
()
>
1
)
{
patternString
=
TRAILING_SLASH_PATTERN
.
matcher
(
patternString
).
replaceAll
(
""
);
}
return
Tag
.
of
(
"uri"
,
patternString
);
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java
View file @
70aa7887
...
...
@@ -112,7 +112,7 @@ public final class WebMvcTags {
if
(
request
!=
null
)
{
String
pattern
=
getMatchingPattern
(
request
);
if
(
pattern
!=
null
)
{
if
(
ignoreTrailingSlash
)
{
if
(
ignoreTrailingSlash
&&
pattern
.
length
()
>
1
)
{
pattern
=
TRAILING_SLASH_PATTERN
.
matcher
(
pattern
).
replaceAll
(
""
);
}
return
Tag
.
of
(
"uri"
,
pattern
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcTagsTests.java
View file @
70aa7887
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -52,12 +52,26 @@ class WebMvcTagsTests {
@Test
void
uriTagValueIsBestMatchingPatternWhenAvailable
()
{
this
.
request
.
setAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
"/spring"
);
this
.
request
.
setAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
"/spring
/
"
);
this
.
response
.
setStatus
(
301
);
Tag
tag
=
WebMvcTags
.
uri
(
this
.
request
,
this
.
response
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/spring/"
);
}
@Test
void
uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash
()
{
this
.
request
.
setAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
"/spring/"
);
Tag
tag
=
WebMvcTags
.
uri
(
this
.
request
,
this
.
response
,
true
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/spring"
);
}
@Test
void
uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashKeepSingleSlash
()
{
this
.
request
.
setAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
"/"
);
Tag
tag
=
WebMvcTags
.
uri
(
this
.
request
,
this
.
response
,
true
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/"
);
}
@Test
void
uriTagValueIsRootWhenRequestHasNoPatternOrPathInfo
()
{
assertThat
(
WebMvcTags
.
uri
(
this
.
request
,
null
).
getValue
()).
isEqualTo
(
"root"
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java
View file @
70aa7887
...
...
@@ -39,12 +39,13 @@ import static org.mockito.Mockito.mock;
* @author Brian Clozel
* @author Michael McFadyen
* @author Madhura Bhave
* @author Stephane Nicoll
*/
class
WebFluxTagsTests
{
private
MockServerWebExchange
exchange
;
private
PathPatternParser
parser
=
new
PathPatternParser
();
private
final
PathPatternParser
parser
=
new
PathPatternParser
();
@BeforeEach
void
setup
()
{
...
...
@@ -53,12 +54,28 @@ class WebFluxTagsTests {
@Test
void
uriTagValueIsBestMatchingPatternWhenAvailable
()
{
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
this
.
parser
.
parse
(
"/spring"
));
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
this
.
parser
.
parse
(
"/spring/"
));
this
.
exchange
.
getResponse
().
setStatusCode
(
HttpStatus
.
MOVED_PERMANENTLY
);
Tag
tag
=
WebFluxTags
.
uri
(
this
.
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/spring/"
);
}
@Test
void
uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash
()
{
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
this
.
parser
.
parse
(
"/spring/"
));
Tag
tag
=
WebFluxTags
.
uri
(
this
.
exchange
,
true
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/spring"
);
}
@Test
void
uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashKeepSingleSlash
()
{
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
this
.
parser
.
parse
(
"/"
));
Tag
tag
=
WebFluxTags
.
uri
(
this
.
exchange
,
true
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"/"
);
}
@Test
void
uriTagValueIsRedirectionWhenResponseStatusIs3xx
()
{
this
.
exchange
.
getResponse
().
setStatusCode
(
HttpStatus
.
MOVED_PERMANENTLY
);
...
...
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