tracker issue : CF-4021952

select a category, or use search below
(searches all categories and all time range)

Cached components with closures will error when the closure is called

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Dan Switzer / Dan Switzer (Dan Switzer)

Created: 07/16/2015

Components: Language, Closures

Versions: 10.0

Failure Type: Crash

Found In Build/Fixed In Build: Final /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 3

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 24, 2019 using build 2016.0.01.298513
Problem Description:
If you have a component that declares a closure, executing the closure from a cached version of the component fails when run outside of the original request.

NOTE: The CF10 docs do indicate that a closure can't call a UDF, but Chandan Kumar (who claims to have worked on closures), says this is not accurate and that they should work. They do indeed work correct on first call:

Steps to Reproduce:
Extract the attached example and run the cache-test.cfm test. The first time you run it, run it will succeed. If you run it again within 10 seconds, it will error.

The code checks if the object exists in cache and if not, creates a new component. It then does a second call, which should grab the object out of cache. On the first run, both tests succeed. On a secondary call, the closure seems to lose references to the scopes and both runs fail.

Actual Result:
java.lang.IllegalArgumentException: Response cannot be null
	at coldfusion.jsp.ServletResponseWrapper.<init>(
	at coldfusion.jsp.HttpServletResponseWrapper.<init>(
	at coldfusion.jsp.JspWriterIncludeResponse.<init>(
	at coldfusion.runtime.NeoPageContext.pushBody(
	at coldfusion.runtime.NeoPageContext.pushBody(
	at coldfusion.filter.SilentFilter.invoke(
	at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(
	at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(
	at coldfusion.filter.FunctionAccessFilter.invoke(
	at coldfusion.runtime.UDFMethod.runFilterChain(
	at coldfusion.runtime.UDFMethod.invoke(
	at coldfusion.runtime.CfJspPage._invokeUDF(
	at cfuser2ecfc808700091$func_CF_ANONYMOUSCLOSURE_0.runFunction....

Expected Result:
The closure should execute as expected--and the way it does on the initial request.

Any Workarounds:
The only workaround is to not use closures.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4021952

External Customer Info:
External Company:  
External Customer Name: Dan
External Customer Email:  
External Test Config: My Hardware and Environment details:

I'm currently running CF10u16 (10,0,16,293499) on CentOS. I've tested under Java 1.8.0_45, as well as the default JVM that ships with ColdFusion 10 (1.7.x). It fails under both cases.

I've also verified the bug exists in CF10 under Windows.

A co-worker is also seeing the code failing while running on Mac under both CF10 and CF11.


  1. July 16, 2015 00:00:00:


[subscribe] Vote must be between 25 and 4000 characters
Vote by External U.
6633 | July 18, 2015 02:40:54 PM GMT
Just to expand on this issue, it anytime you store a closure in a variable that will outlive the current request, attempts to invoke the closure on an additional request will error with the "Response cannot be null" message.
Comment by External U.
6631 | August 11, 2015 09:57:37 AM GMT
Can some one provide some insight on this fix? Is this going to be rolled out to all effected editions (i.e. CF10+)? When will the fix be available? It would be nice to know when this fix will be available, as we could refactor some of our code that were we had to work around the issue by moving back to closures.
Comment by External U.
6632 | November 02, 2015 10:16:31 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513) using the following repro case: Application.cfc ----------- component { = "ticket_4021952";} ----------- MyCFC.cfc ----------- component output=false { myFunctionExpression = function() {return myFunction();}; public function myFunction() output=false {return "my result";}/* In CF11, output=false triggers "java.lang.IllegalArgumentException: Response cannot be null" */ public function getMyFunctionExpressionResult() {return myFunctionExpression();} } ----------- index.cfm ----------- <cfscript> public MyCFC function getCachedObject(){ var result=""; var myCacheID = "myCachedObject"; if(!cacheIDExists(myCacheID)) { var myObject = new MyCFC(); cachePut(myCacheID, myObject, createTimespan(0, 0, 0, 10), createTimespan(0, 0, 0, 10)); } if(cacheIDExists(myCacheID)) { result = cacheGet(myCacheID); } return result; } myObject1 = getCachedObject(); writeOutput(myObject1.getMyFunctionExpressionResult()); myObject2 = getCachedObject(); writeOutput(myObject2.getMyFunctionExpressionResult()); </cfscript> ----------- Thanks!, -Aaron
Comment by Aaron N.
31170 | August 24, 2019 06:24:33 AM GMT