SpringSource/spring-framework — pull request #238 by wesleyhall (2013-02-21 14:23:24+00:00)
Title: Fix DefaultMockMvcBuilder fluent API generic type

Changed upper bound of generic parameter for DefaultMockMvcBuilder from
MockMvcBuilder to DefaultMockMvcBuilder to allow for ongoing method
chaining in the fluent API style.

Prior to this commit there was a problem in that repeated chained calls made to the DefaultMockMvcBuilder class would result in the returning of an MockMvcBuilder typed reference. Since all the useful chaining methods are on the DefaultMockMvcBuilder subclass this resulted in the loss of any useful chained (fluent API) type usage of the builder class. The reason for this problem is that in chaining calls the compiler 'loses' the knowledge that the type being returned is actually a DefaultMockMvcBuilder and returns to the type specified in the 'extends' part of the generic type definition. By tightening the bounds of the generic type to 'extends DefaultMockMvcBuilder', clients of the class can continue to call methods on the returned reference and still have access to the DefaultMockMvcBuilder methods.

A test has been added matching the original example in the Jira issue, which now compiles successfully.

Issue: SPR-10277