tracker issue : CF-3321655

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

bug in for(element in array)

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/30/2012

Components: Language

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / Some users will encounter

Locale/System: English / Win All

Vote Count: 0

Problem Description:
[see steps to reproduce]

Steps to Reproduce:
numbers = ["tahi", "rua", "toru", "wha"];

for (number in numbers){
	writeOutput(number & "<br />");
	if (number == "tahi"){
		arrayAppend(numbers, "rima");
	}
}
writeDump(numbers);

Actual Result:
Error Occurred While Processing Request
 
The error occurred in C:/ColdFusion10/cfusion/wwwroot/shared/git/blogExamples/arrays/forInAppend.cfm: line 4
2 : numbers = ["tahi", "rua", "toru", "wha"];
3 : 
4 : for (number in numbers){


Expected Result:
For it to not error.

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

Watson Bug ID:	3321655

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Right now, it throws ConcurrentModificationException since we are working on the Java's List Iterator. However, this behaviour is different from <cfloop> as well as for..in for struct. Since we allow modification of the data on which we are iterating, we should fix this.
Comment by Rupesh K.
18224 | September 03, 2012 12:37:10 PM GMT
cfloop loops over the collection based on starting index to collection size (collection count). It does not get handle of iterator over array and hence modification of array is permissible. But for-in works with iterator and breaks when underlying collection is being modified.
Comment by Awdhesh K.
18225 | May 10, 2013 12:43:52 AM GMT