Status/Resolution/Reason: Closed/Withdrawn/Duplicate
Reporter/Name(from Bugbase): jon anderson / jon anderson (jon anderson)
Created: 09/29/2016
Components: Language
Versions: 11.0
Failure Type:
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Normal / All users will encounter
Locale/System: ALL / Windows 10 64 bit
Vote Count: 0
Duplicate ID: CF-4129321
Problem Description:
The .map() member function is available on arrays in ColdFusion. The documentation (here: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-e-g/getmetadata.html) states that the struct returned from getMetaData() contains, at the "functions" key, an "Array of metadata structures for the component’s functions.". When you dump it, it's shown as an array and labeled as such. But if you try to call member functions on the "array" (like .map() or .reduce()) it cannot find them. I suspect what's actually being returned is a raw java array rather than a CF array. I assume whenever I see "array" in the documentation it's not referring to other than a ColdFusion array unless explicitly stated, so it appears there's either a bug or that the docs are inaccurate.
As a side note the quick fix may be to update the docs to reflect reality. I would suggest making a change to what the getMetaData() function returns, though. It seems best to provide ColdFusion things in all cases except where ColdFusion can't do something but Java can. In this case CF does have Arrays, so it would make sense to provide one.
Steps to Reproduce:
var data = getMetaData(myComponentInstance);
writeDump(isArray(data.functions)); // true
var bug = data.functions.map(function(item) {
return item.name;
});
Actual Result:
exception with message: "The map method was not found."
detail: "Either there are no methods with the specified method name and argument types or the map method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity."
Expected Result:
The map member function is found on the array and runs.
Any Workarounds:
Use a function like this to transfer the functions "array" members to a ColdFusion array before running map on the return value. (I believe you can also use a for loop on the java array - that still works).
array function javaArrayToCFArray(any jar) {
local.out = [];
for (local.i in arguments.jar) {
local.out.add(local.i);
}
return local.out;
}
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4194158
External Customer Info:
External Company:
External Customer Name: jon anderson
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: