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

HttpMessageConverter read and write methods have restrictive type annotations [SPR-6848] #11514

Closed
spring-projects-issues opened this issue Feb 15, 2010 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 15, 2010

Alex Antonov opened SPR-6848 and commented

When trying to implement a HttpMessageConverter for Google Protocol Buffers I've run into a limitation by the write and read method signatures that require an exact type T.
With Protocol Buffers, as with many other types of marshaling systems, there is a base class, Message in this case, that all exact classes extend or implement.
canRead and canWrite methods do declare the relaxed and appropriate signature of <? extends T>, however in the read and write methods its being set to exactly T.

This prevents of calling the converter's write and read methods with passing an implementation of Message as an argument, since it does not conform to the generic restrictions set forth by the interfaces.


Affects: 3.0 GA

Issue Links:

Referenced from: commits 4ae1709

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Arjen, this is worth a quick look before we proceed with the 3.0.1 release: Since we relaxed the canRead and canWrite signatures for 3.0.1 already, we might also take this into account still.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 16, 2010

Juergen Hoeller commented

We've relaxed read's Class parameter to:

T read(Class<? extends T> clazz, HttpInputMessage inputMessage)

This allows for specifying subtypes for reading as well, not just for writing (where it's already possibly to pass a subtype instance to the write method).

Note that the canRead and canWrite signatures have already been relaxed as part of #11437, fixed for the Spring 3.0.1 release as well.

This will be available in tonight's 3.0.1 snapshot (586). Feel free to give it an early try!

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 17, 2010

Alex Antonov commented

Juergen, thanks for the quick turn-around. I've given it a try and it works as expected.
Would SpringSource be interested in the code donation for the Google Protocol Buffers HttpMessageConverter to be included in the next Spring release (as proposed in earlier #10927)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants