tracker issue : CF-3806526

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

Line Preceeding Function Call Fails to Execute & Function Executes Twice

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Brien Malone / Brien Malone (BrienMalone)

Created: 08/15/2014

Components: Core Runtime

Versions: 9.0.1

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: 9.0.1 / CF 11

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Win 2008 Server R2

Vote Count: 1

Problem Description: A 'perfect storm' of syntax in CF 9.0.1 can cause coldfusion to execute a function twice and ignore the line preceding the function call.

Steps to Reproduce:

Create a simple function that accepts a struct:
public void function SimpleFunction1 (struct incomingStruct) {
	WriteOutput("This is SimpleFunction1.<BR />");
}

Call that function with a named, inline struct shortcut:
SimpleFunction1(incomingStruct={item1="ok",item2="go"});

Works fine so far. Now, wrap that function call in a try/catch block:
try{
	SimpleFunction1(incomingStruct={item1="ok",item2="go"});
}
catch (any e){
	rethrow;
	}

Finally, add an instruction above the function call:
try{
        abort; //this command will fail to execute
	SimpleFunction1(incomingStruct={item1="ok",item2="go"});//this function call is executed twice
}
catch (any e){
	rethrow;
	}

Actual Result:
In spite of the abort, the following output will appear on screen:
This is SimpleFunction1.
This is SimpleFunction1.

Expected Result:
The function should execute once. The line preceding the function call should not be ignored.

Any Workarounds:
There are many:
* Don't use a named parameter, just pass in the struct shortcut.
OR
* Assign the struct to a variable and pass the variable in the function call.
OR
* Remove the try catch block

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

Watson Bug ID:	3806526

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

Server 2008 R2

ColdFusion Server Enterprise	9,0,1,274733

Attachments:

Comments:

I have not tested this on 9.0.2, 10, or 11
Comment by External U.
11354 | August 15, 2014 11:57:32 AM GMT
same on 9.0.2 example: <cfscript> public void function SimpleFunction1 (struct incomingStruct) { writelog(application = true, type = "information", file = "sean", text = "This is SimpleFunction1."); } writelog(application = true, type = "information", file = "sean", text = "starting..."); try { writelog(application = true, type = "information", file = "sean", text = "about to call function..."); //this line will never execute. SimpleFunction1(incomingStruct = { item1 = "ok", item2 = "go" }); //this function will execute 2x writelog(application = true, type = "information", file = "sean", text = "function called..."); } catch (any err) { rethrow; } writelog(application = true, type = "information", file = "sean", text = "complete..."); </cfscript>
Comment by External U.
11355 | August 15, 2014 01:42:39 PM GMT
+1 not good to have functions executing twice just because its taking an inline struct and is not the first line in a try/catch
Vote by External U.
11358 | August 15, 2014 01:43:14 PM GMT
Bug is present in CF10, but is fixed in CF11
Comment by External U.
11356 | August 15, 2014 01:56:44 PM GMT
Verified this is fixed in CF10 Update 14 (10,0,14,291717) and CF11 Final (11,0,0,289822). The command before the function call is executed and the function call is executed once. Thanks!, -Aaron
Comment by External U.
11357 | November 23, 2014 09:23:33 PM GMT