Skip to content

Commit 9583b06

Browse files
committed
Polish
Use StringUtils#hasText PR gh-13179
1 parent 4de201a commit 9583b06

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

web/src/main/java/org/springframework/security/web/ObservationFilterChainDecorator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.commons.logging.LogFactory;
3838

3939
import org.springframework.core.log.LogMessage;
40+
import org.springframework.util.StringUtils;
4041

4142
/**
4243
* A {@link org.springframework.security.web.FilterChainProxy.FilterChainDecorator} that
@@ -519,8 +520,8 @@ public KeyValues getLowCardinalityKeyValues(FilterChainObservationContext contex
519520
return KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
520521
.and(CHAIN_POSITION_NAME, String.valueOf(context.getChainPosition()))
521522
.and(FILTER_SECTION_NAME, context.getFilterSection())
522-
.and(FILTER_NAME, (context.getFilterName() != null && !context.getFilterName().isEmpty())
523-
? context.getFilterName() : KeyValue.NONE_VALUE);
523+
.and(FILTER_NAME, (StringUtils.hasText(context.getFilterName())) ? context.getFilterName()
524+
: KeyValue.NONE_VALUE);
524525
}
525526

526527
@Override

web/src/main/java/org/springframework/security/web/server/ObservationWebFilterChainDecorator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.springframework.lang.Nullable;
3636
import org.springframework.util.Assert;
37+
import org.springframework.util.StringUtils;
3738
import org.springframework.web.server.ServerWebExchange;
3839
import org.springframework.web.server.WebFilter;
3940
import org.springframework.web.server.WebFilterChain;
@@ -689,8 +690,8 @@ public KeyValues getLowCardinalityKeyValues(WebFilterChainObservationContext con
689690
return KeyValues.of(CHAIN_SIZE_NAME, String.valueOf(context.getChainSize()))
690691
.and(CHAIN_POSITION_NAME, String.valueOf(context.getChainPosition()))
691692
.and(FILTER_SECTION_NAME, context.getFilterSection())
692-
.and(FILTER_NAME, (context.getFilterName() != null && !context.getFilterName().isEmpty())
693-
? context.getFilterName() : KeyValue.NONE_VALUE);
693+
.and(FILTER_NAME, (StringUtils.hasText(context.getFilterName())) ? context.getFilterName()
694+
: KeyValue.NONE_VALUE);
694695
}
695696

696697
@Override

0 commit comments

Comments
 (0)