@@ -708,20 +708,21 @@ public RequestMappingInfo build() {
708708 PathPatternsRequestCondition pathPatternsCondition = null ;
709709 PatternsRequestCondition patternsCondition = null ;
710710
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 {
712719 patternsCondition = (ObjectUtils .isEmpty (this .paths ) ?
713720 EMPTY_PATTERNS :
714721 new PatternsRequestCondition (
715- this .paths , null , this .options .getPathMatcher () ,
722+ this .paths , null , this .options .pathMatcher ,
716723 this .options .useSuffixPatternMatch (), this .options .useTrailingSlashMatch (),
717724 this .options .getFileExtensions ()));
718725 }
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- }
725726
726727 ContentNegotiationManager manager = this .options .getContentNegotiationManager ();
727728
@@ -784,9 +785,11 @@ public MutateBuilder(RequestMappingInfo other) {
784785 @ Override
785786 @ SuppressWarnings ("deprecation" )
786787 public Builder paths (String ... paths ) {
787- if (this .options .patternParser != null ) {
788+ PathPatternParser parser = this .options .getPatternParserToUse ();
789+
790+ if (parser != null ) {
788791 this .pathPatternsCondition = (ObjectUtils .isEmpty (paths ) ?
789- EMPTY_PATH_PATTERNS : new PathPatternsRequestCondition (this . options . patternParser , paths ));
792+ EMPTY_PATH_PATTERNS : new PathPatternsRequestCondition (parser , paths ));
790793 }
791794 else {
792795 this .patternsCondition = (ObjectUtils .isEmpty (paths ) ?
@@ -873,6 +876,9 @@ public RequestMappingInfo build() {
873876 */
874877 public static class BuilderConfiguration {
875878
879+ private static PathPatternParser defaultPatternParser = new PathPatternParser ();
880+
881+
876882 @ Nullable
877883 private PathPatternParser patternParser ;
878884
@@ -954,6 +960,20 @@ public PathMatcher getPathMatcher() {
954960 return this .pathMatcher ;
955961 }
956962
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+
957977 /**
958978 * Set whether to apply trailing slash matching in PatternsRequestCondition.
959979 * <p>The default was changed in 6.0 from {@code true} to {@code false} in
0 commit comments