@@ -589,8 +589,7 @@ public void register(T mapping, Object handler, Method method) {
589
589
this .readWriteLock .writeLock ().lock ();
590
590
try {
591
591
HandlerMethod handlerMethod = createHandlerMethod (handler , method );
592
- assertMappedPathMethodMapping (handlerMethod , mapping );
593
- assertUniqueMethodMapping (handlerMethod , mapping );
592
+ validateMethodMapping (handlerMethod , mapping );
594
593
this .mappingLookup .put (mapping , handlerMethod );
595
594
596
595
List <String > directUrls = getDirectUrls (mapping );
@@ -616,28 +615,23 @@ public void register(T mapping, Object handler, Method method) {
616
615
}
617
616
}
618
617
619
- /**
620
- * Assert that the supplied {@code mapping} maps the supplied {@link HandlerMethod}
621
- * to explicit, non-empty paths.
622
- * @since 5.2
623
- * @see StringUtils#hasText(String)
624
- */
625
- private void assertMappedPathMethodMapping (HandlerMethod handlerMethod , T mapping ) {
618
+ private void validateMethodMapping (HandlerMethod handlerMethod , T mapping ) {
619
+ // Assert that the supplied mapping maps the supplied HandlerMethod
620
+ // to explicit, non-empty paths.
626
621
if (!getMappingPathPatterns (mapping ).stream ().allMatch (StringUtils ::hasText )) {
627
622
throw new IllegalStateException (String .format ("Missing path mapping. " +
628
623
"Handler method '%s' in bean '%s' must be mapped to a non-empty path. " +
629
624
"If you wish to map to all paths, please map explicitly to \" /**\" or \" **\" ." ,
630
- handlerMethod , handlerMethod .getBean ()));
625
+ handlerMethod , handlerMethod .getBean ()));
631
626
}
632
- }
633
627
634
- private void assertUniqueMethodMapping ( HandlerMethod newHandlerMethod , T mapping ) {
635
- HandlerMethod handlerMethod = this .mappingLookup .get (mapping );
636
- if (handlerMethod != null && !handlerMethod .equals (newHandlerMethod )) {
628
+ // Assert that the supplied mapping is unique.
629
+ HandlerMethod existingHandlerMethod = this .mappingLookup .get (mapping );
630
+ if (existingHandlerMethod != null && !existingHandlerMethod .equals (handlerMethod )) {
637
631
throw new IllegalStateException (
638
- "Ambiguous mapping. Cannot map '" + newHandlerMethod .getBean () + "' method \n " +
639
- newHandlerMethod + "\n to " + mapping + ": There is already '" +
640
- handlerMethod .getBean () + "' bean method\n " + handlerMethod + " mapped." );
632
+ "Ambiguous mapping. Cannot map '" + handlerMethod .getBean () + "' method \n " +
633
+ handlerMethod + "\n to " + mapping + ": There is already '" +
634
+ existingHandlerMethod .getBean () + "' bean method\n " + existingHandlerMethod + " mapped." );
641
635
}
642
636
}
643
637
0 commit comments