Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestMapping maps root-controller handler methods with double slashes [SPR-12975] #17566

Closed
spring-issuemaster opened this issue May 3, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented May 3, 2015

Christopher Smith opened SPR-12975 and commented

The handler-mapping builder is adding an extra slash to the beginning of handler mappings, causing MockMvc tests to fail because of strict matching in MockMvc.

@Controller
@CompileStatic
@RequestMapping("/")
class StaticPagesHtmlController {
    @RequestMapping("")
    public String home() {
        "index2"
    }

    @RequestMapping("about")
    String aboutMain() {
        "about/index"
    }
}
2015-05-04 01:37:09.954  INFO   --- [           main] ilder$StaticRequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.artsquare.gallery.web.html.StaticPagesHtmlController.home()
2015-05-04 01:37:09.954  INFO   --- [           main] ilder$StaticRequestMappingHandlerMapping : Mapped "{[//about],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.artsquare.gallery.web.html.StaticPagesHtmlController.aboutMain()

It looks like a potential defensive rule that adds the slash to the root-root mapping is also adding erroneous, breaking, slashes to the other mappings.


Affects: 4.1.6

Issue Links:

  • #17567 MockMvc isn't matching handler mappings

Referenced from: commits bf423b2, a80d0e8, 76beb36

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 8, 2015

Arjen Poutsma commented

PR at #795

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 8, 2015

Sam Brannen commented

Fixed as described in GitHub commits a80d0e8 (4.2 RC1) and bf423b2 (4.1.7):

Remove duplicate separators when combining paths

Prior to this commit, AntPathMatcher would not correctly combine a path
that ends with a separator with a path that starts with a separator.
For example, /foo/ + /bar combined into /foo//bar.

Specifically, this commit:

  • Removes the duplicated separator in combined paths

  • Improves RequestMappingInfo's toString() representation

  • Fixes Javadoc formatting in AntPathMatcher

  • Polishes AntPathMatcherTests

  • Polishes Javadoc in AbstractRequestCondition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.