Title:
getPageContext().getResponse().getContentType() throws UnsupportedOperationException
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()
Created: 09/26/2017
Components: Installation/Config, JEE Deployment
Versions: 2016,2018
Failure Type: Others
Found In Build/Fixed In Build: 2016 / 312568
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Platforms All
Vote Count: 3
Problem Description:
getPageContext().getResponse().getContentType() throws UnsupportedOperationException
Adobe's coldfusion.jsp.ServletResponseWrapper class doesn't fully implement the spec for the ServletResonse interface and throws an exception from the getContentType() object. This used to work in previous versions of CF, but was broken at some point in 2016.
The ColdBox framework uses this with its event caching feature to see what content type has been set in the response. Please implement the full javax.servlet.ServletResponse interface.
Note, the same issue is present with the setCharacterEncoding() method on the response wrapper.
Steps to Reproduce:
getPageContext().getResponse().getContentType()
Actual Result:
java.lang.UnsupportedOperationException
at coldfusion.jsp.ServletResponseWrapper.getContentType(ServletResponseWrapper.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at coldfusion.runtime.StructBean.invoke(StructBean.java:508)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3168)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3068)
at cfBootstrap2ecfc1271759093$funcPROCESSCOLDBOXREQUEST.runFunction(/coldbox/system/Bootstrap.cfc:241)
Expected Result:
The actual content type of the servlet response to be returned.
Any Workarounds:
You can bypass Adobe's response wrapper like so, but this requires you to first check if you're dealing with a response wrapper at all.
getPageContext().getResponse().getResponse().getContentType()
Attachments:
Comments: