tracker issue : CF-3951546

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

Null Pointer Exception sometimes caused by function expression (closure) inside literal struct

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Peter Boughton / Peter Boughton (Peter Boughton)

Created: 03/11/2015

Components: Language

Versions: 11.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: ALL / Platforms All

Vote Count: 1

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
The code worked fine on CF11 u2.

Testing CF11 u5 pre2 and it gives a Null Pointer Exception - sometimes. Sometimes it works fine - just refreshing the page results in different behaviour with no code changes, which is REALLY AWESOME! ¬_¬

Stack trace:
java.lang.NullPointerException
	at coldfusion.runtime.CFPage.URLEncodedFormat(CFPage.java:4140)
	at cfShareUtils2ecfc639456635$func_CF_ANONYMOUSCLOSURE_3.runFunction(<path>\ShareUtils.cfc:40)
	at coldfusion.runtime.Closure.invoke(Closure.java:100) 
	at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383) 
	at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) 
	at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334) 
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231) 
	at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2845) 
	at cfShareUtils2ecfc639456635$funcGETSHARETO.runFunction(<path>\ShareUtils.cfc:117) 
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487) 
	at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383) 
	at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) 
	at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334) 
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231) 
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:643) 
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:432) 
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:402) 
	at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2483) 

Line 40 of ShareUtils.cfc is this:

	& '?url=' & UrlEncodedFormat(PageUrl)

In context it is in the twitter function below:

		variables.ShareUrls =

			{ 'facebook': function(PageUrl) // no support for ShareText
				{
					return 'http://www.facebook.com/sharer.php'
						& '?u=' & UrlEncodedFormat(PageUrl)
						;
				}
//...

			, 'twitter': function(PageUrl,ShareText)
				{
					return 'https://twitter.com/share'
						& '?url=' & UrlEncodedFormat(PageUrl)
						& '&text=' & UrlEncodedFormat(ShareText)
						;
				}

//...
			};

Of course all that formatting is about to be lost because this bugbase software is shit and Adobe can't be bothered to fix it (3840576)

Not sure there's any point creating a reproducible test case since you'll just ignore it and use your own version that "pretty much does the same thing". :/

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

Watson Bug ID:	3951546

External Customer Info:
External Company:  
External Customer Name: Peter
External Customer Email:

Attachments:

  1. March 13, 2015 00:00:00: 1_test_3951546.zip

Comments:

The bug is in function expressions - declaring the function traditionally and referencing it works around the problem. function t(PageUrl,ShareText) { return 'https://twitter.com/share' & '?url=' & UrlEncodedFormat(PageUrl) & '&text=' & UrlEncodedFormat(ShareText) ; } ... , 'twitter': t ... The times when the function works is immediately after resetting the test suite (i.e. ApplicationStop) - the first following request it works then every subsequent request it fails. Removing the singleton attribute from the component causes it to work each time (though obviously at the expense of performance due to not having a single instance). Presumably whatever Coldbox does to cache singletons is somehow resulting in CF breaking the closure or something.
Comment by External U.
8099 | March 11, 2015 12:27:06 PM GMT
We are looking into this issue and will provide an update soon. Would it possible for you to attach an isolated reproducible test to help us move fast on this issue? Appreciate your feedback and time on this issue.
Comment by Vamseekrishna N.
8100 | March 13, 2015 01:04:55 AM GMT
With respect to the other point you raised about the formatting being lost, we've informed the concerned team to look into this. Will let you know once we hear from them. Thanks again.
Comment by Vamseekrishna N.
8101 | March 13, 2015 01:07:57 AM GMT
Thanks for pushing regarding the bugbase Vamseekrishna. I've reproduced the issue outside of Coldbox by storing the CFC in Application scope - see attached zip; on the first request to test.cfm it works fine, but the second request has the null pointer exception.
Comment by External U.
8102 | March 13, 2015 07:36:37 AM GMT
Thanks Peter for the repro code. We will look into the issue and update you on this as soon as possible. Thanks again :)
Comment by Suchika S.
8103 | March 13, 2015 09:58:07 AM GMT
+1 ......................
Vote by External U.
8105 | September 28, 2015 10:39:38 PM GMT
UrlEncodedFormat() is not working on CF11 U7.
Comment by External U.
8104 | April 14, 2016 12:04:24 PM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
31182 | August 24, 2019 09:02:06 AM GMT