@@ -708,20 +708,21 @@ public RequestMappingInfo build() {
708
708
PathPatternsRequestCondition pathPatternsCondition = null ;
709
709
PatternsRequestCondition patternsCondition = null ;
710
710
711
- if (this .options .getPathMatcher () != null ) {
711
+ PathPatternParser parser = this .options .getPatternParserToUse ();
712
+
713
+ if (parser != null ) {
714
+ pathPatternsCondition = (ObjectUtils .isEmpty (this .paths ) ?
715
+ EMPTY_PATH_PATTERNS :
716
+ new PathPatternsRequestCondition (parser , this .paths ));
717
+ }
718
+ else {
712
719
patternsCondition = (ObjectUtils .isEmpty (this .paths ) ?
713
720
EMPTY_PATTERNS :
714
721
new PatternsRequestCondition (
715
- this .paths , null , this .options .getPathMatcher () ,
722
+ this .paths , null , this .options .pathMatcher ,
716
723
this .options .useSuffixPatternMatch (), this .options .useTrailingSlashMatch (),
717
724
this .options .getFileExtensions ()));
718
725
}
719
- else {
720
- PathPatternParser parser = (this .options .getPatternParser () != null ?
721
- this .options .getPatternParser () : new PathPatternParser ());
722
- pathPatternsCondition = (ObjectUtils .isEmpty (this .paths ) ?
723
- EMPTY_PATH_PATTERNS : new PathPatternsRequestCondition (parser , this .paths ));
724
- }
725
726
726
727
ContentNegotiationManager manager = this .options .getContentNegotiationManager ();
727
728
@@ -784,9 +785,11 @@ public MutateBuilder(RequestMappingInfo other) {
784
785
@ Override
785
786
@ SuppressWarnings ("deprecation" )
786
787
public Builder paths (String ... paths ) {
787
- if (this .options .patternParser != null ) {
788
+ PathPatternParser parser = this .options .getPatternParserToUse ();
789
+
790
+ if (parser != null ) {
788
791
this .pathPatternsCondition = (ObjectUtils .isEmpty (paths ) ?
789
- EMPTY_PATH_PATTERNS : new PathPatternsRequestCondition (this . options . patternParser , paths ));
792
+ EMPTY_PATH_PATTERNS : new PathPatternsRequestCondition (parser , paths ));
790
793
}
791
794
else {
792
795
this .patternsCondition = (ObjectUtils .isEmpty (paths ) ?
@@ -873,6 +876,9 @@ public RequestMappingInfo build() {
873
876
*/
874
877
public static class BuilderConfiguration {
875
878
879
+ private static PathPatternParser defaultPatternParser = new PathPatternParser ();
880
+
881
+
876
882
@ Nullable
877
883
private PathPatternParser patternParser ;
878
884
@@ -954,6 +960,20 @@ public PathMatcher getPathMatcher() {
954
960
return this .pathMatcher ;
955
961
}
956
962
963
+ /**
964
+ * Return the {@code PathPatternParser} to use, the one set explicitly
965
+ * or falling back on a default instance if both {@code PathPatternParser}
966
+ * and {@code PathMatcher} are not set.
967
+ * @since 6.1.2
968
+ */
969
+ @ Nullable
970
+ public PathPatternParser getPatternParserToUse () {
971
+ if (this .patternParser == null && this .pathMatcher == null ) {
972
+ return defaultPatternParser ;
973
+ }
974
+ return this .patternParser ;
975
+ }
976
+
957
977
/**
958
978
* Set whether to apply trailing slash matching in PatternsRequestCondition.
959
979
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
0 commit comments