spring-projects / spring-projects/spring-framework
BufferedImageHttpMessageConverter cannot convert to a media type it claims it can [SPR-15037]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Dave Syer opened SPR-15037 and commented
The samples in spring-secuirty-oauth2 suffer from this problem. I think it is probably platform/browser dependent because I couldn't reproduce it till today, and now I can (Ubuntu 14.04, Chrome 50.0.2661.86). The browser sends
[text/html, application/xhtml+xml, image/webp, application/xml;q=0.9, */*;q=0.8]
and the app sends back a response entity with Content-Type: image/jpeg. The converter comes in and claims that it can convert to
[image/vnd.wap.wbmp, image/png, image/x-png, image/jpeg, image/bmp, image/gif]
And then fails to do the conversion to the highest priority media type:
Dec 21, 2016 8:35:20 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/tonr2] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Only integral single-band bilevel image is supported.] with root cause
java.lang.IllegalArgumentException: Only integral single-band bilevel image is supported.
at com.sun.imageio.plugins.wbmp.WBMPImageWriter.checkSampleModel(WBMPImageWriter.java:313)
at com.sun.imageio.plugins.wbmp.WBMPImageWriter.write(WBMPImageWriter.java:171)
at org.springframework.http.converter.BufferedImageHttpMessageConverter.write(BufferedImageHttpMessageConverter.java:225)
at org.springframework.http.converter.BufferedImageHttpMessageConverter.write(BufferedImageHttpMessageConverter.java:67)
...
The sample is old and still uses Spring 4.0.9, but I tried with 4.3.4 (just add <spring.version>4.3.4.RELEASE</spring.version> to the properties in the tonr2 pom.xml) and the problem is the same.
Affects: 4.3.4
Reference URL: https://github.com/spring-projects/spring-security-oauth/issues/427
Issue Links:
- #18985 Rendering of a Resource should try to derive the served media type
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with org.springframework.http.converter.BufferedImageHttpMessageConverter, especially its write methods and the media types shown in the report. Reproduce the failure using the listed browser Accept header and an image/jpeg response, then verify that media-type selection no longer attempts an unsupported conversion or raises the reported exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100