Skip to content

Avoid misconfiguration of controller overrides [DATAREST-1591] #1946

Closed
@spring-projects-issues

Description

@spring-projects-issues

Karsten Ludwig Hauser opened DATAREST-1591 and commented

Calling

mvc.perform(MockMvcRequestBuilders.patch("/person/" + EXPECTED_PERSON_ID).contentType(JSON_PATCH_JSON)
                .content(patchPayload)).andDo(print()).andExpect(status().isNoContent());

results in

MockHttpServletRequest:
      HTTP Method = PATCH
      Request URI = /person/1
       Parameters = {}
          Headers = [Content-Type:"application/json-patch+json;charset=UTF-8", Content-Length:"52"]
             Body = [{"op":"replace","path":"/firstName","value":"Max"}]
    Session Attrs = {}Handler:
             Type = nullAsync:
    Async started = false
     Async result = nullResolved Exception:
             Type = org.springframework.web.HttpRequestMethodNotSupportedExceptionModelAndView:
        View name = null
             View = null
            Model = nullFlashMap:
       Attributes = nullMockHttpServletResponse:
           Status = 405
    Error message = Request method 'PATCH' not supported
          Headers = [Allow:"GET"]
     Content type = null
             Body = 
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

when a custom RestController having the same mapping path as the repository.

Please check with the project behind the reference url.

 


Affects: 3.3.6 (Neumann SR6)

Reference URL: https://github.com/khauser/JsonPatchShowcase

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions