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

MockHttpServletResponse API is incompatible with Servlet 3.0 HttpServletResponse [SPR-8529] #13173

Closed
spring-projects-issues opened this issue Jul 13, 2011 · 3 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Pranay Kumar opened SPR-8529 and commented

We have upgraded to Tomcat7 and also upgraded with servlet3.0 jar. Now while compiling our code which is creating a new instance of MockHttpServletResponse we are getting compolation error as:--

getHeaders(java.lang.String) in org.springframework.mock.web.MockHttpServletResponse cannot implement getHeaders(java.lang.String) in javax.servlet.http.HttpServletResponse; attempting to use incompatible return type
[groovyc] found : java.util.List<java.lang.Object>
[groovyc] required: java.util.Collection<java.lang.String>
[groovyc] MockHttpServletResponse response = new MockHttpServletResponse() {

After seeing the code we found that return type of getHeaders() functon have been now changed to "java.util.Collection<java.lang.String>" while spring still returning as "List". We are usnig spring 3.0.3. We checked the code in spring 3.0.5 which also have same issue.


Affects: 3.1 M2

Referenced from: commits cc725d7, 18ab057

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Thanks for logging this, Pranay! Certainly an issue, and we'll take care of it for RC1.

@spring-projects-issues
Copy link
Collaborator Author

Pranay Kumar commented

Thanks for taking it care of it.
Not sure if this is the right place to ask this question or not, Do we have any expected release schedule date for 3.1 RC1. If yes, please share, this will help us in planning to update spring.

Thanks,
Pranay

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This is due to the addition of the getHeader/getHeaders method to HttpServletResponse in the Servlet 3.0 API, whereas Spring had methods of the same name as extensions on its mock classes before. I've fixed this for Spring 3.1 where we have a Servlet 3.0 theme anyway. I've also generally upgraded our mocks to support Servlet 3.0 API methods where possible (with a couple of limitations as stated in the javadoc), while retaining compatibility with Servlet 2.4/2.5 as well.

Our Spring 3.1 MockHttpServletResponse class is slightly incompatible with its Spring 3.0 version now since getHeader/getHeaders always returns Strings. I've added separate getHeaderValue/getHeaderValues methods for raw value access which users need to migrate to now when not wanting Strings. For that reason, this is not an ideal backport candidate and will very likely only be fixed in the Spring 3.1 branch.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants