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
b22bb7ea
Commit
b22bb7ea
authored
Nov 13, 2020
by
Peter Paul Bakker
Committed by
Stephane Nicoll
Nov 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary pattern compilation in WebFluxTags
See gh-24147
parent
4961599f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
WebFluxTags.java
...boot/actuate/metrics/web/reactive/server/WebFluxTags.java
+11
-3
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java
View file @
b22bb7ea
...
...
@@ -49,7 +49,7 @@ public final class WebFluxTags {
private
static
final
Tag
EXCEPTION_NONE
=
Tag
.
of
(
"exception"
,
"None"
);
private
static
final
Pattern
TRAILING_SLASH_PATTERN
=
Pattern
.
compile
(
"/$
"
);
private
static
final
Pattern
FORWARD_SLASHES_PATTERN
=
Pattern
.
compile
(
"//+
"
);
private
WebFluxTags
()
{
}
...
...
@@ -108,7 +108,7 @@ public final class WebFluxTags {
if
(
pathPattern
!=
null
)
{
String
patternString
=
pathPattern
.
getPatternString
();
if
(
ignoreTrailingSlash
&&
patternString
.
length
()
>
1
)
{
patternString
=
TRAILING_SLASH_PATTERN
.
matcher
(
patternString
).
replaceAll
(
""
);
patternString
=
removeTrailingSlash
(
patternString
);
}
if
(
patternString
.
isEmpty
())
{
return
URI_ROOT
;
...
...
@@ -131,10 +131,18 @@ public final class WebFluxTags {
return
URI_UNKNOWN
;
}
private
static
String
removeTrailingSlash
(
String
text
)
{
if
(!
StringUtils
.
hasLength
(
text
))
{
return
text
;
}
return
text
.
endsWith
(
"/"
)
?
text
.
substring
(
0
,
text
.
length
()
-
1
)
:
text
;
}
private
static
String
getPathInfo
(
ServerWebExchange
exchange
)
{
String
path
=
exchange
.
getRequest
().
getPath
().
value
();
String
uri
=
StringUtils
.
hasText
(
path
)
?
path
:
"/"
;
return
uri
.
replaceAll
(
"//+"
,
"/"
).
replaceAll
(
"/$"
,
""
);
String
singleSlashes
=
FORWARD_SLASHES_PATTERN
.
matcher
(
uri
).
replaceAll
(
"/"
);
return
removeTrailingSlash
(
singleSlashes
);
}
/**
...
...
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