Title:
Inconsistent TypedArrayInvalidDataTypeException with cfimport and relative CFC paths
| View in TrackerStatus/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Alexandre P. / ()
Created: 09/16/2019
Components: Language, Functions
Versions: 2018
Failure Type: Incorrect w/Workaround
Found In Build/Fixed In Build: 2018.0.04.314546 /
Priority/Frequency: Normal / Most users will encounter
Locale/System: / Win 2016
Vote Count: 1
Problem Description: A `TypedArrayInvalidDataTypeException` may be thrown unexpectedly when using cfc-typed-array return types with imported component names.
Steps to Reproduce:
1. Create the following folder structure:
index.cfm
root/
nested/
Test.cfc (empty CFC - just <cfcomponent></cfcomponent>)
Factory.cfc
2. Add code to the following files:
- index.cfm:
<cfimport path="root.*">
<cfset new Factory().createTests()>
-root/Factory.cfc
<cfimport path="nested.*">
<cfcomponent>
<cffunction name="createTests" access="public" returntype="Test[]">
<cfreturn [new Test(), new Test()]>
</cffunction>
</cfcomponent>
3. Run index.cfm
4. Create a root/nested/Test2 component (<cfcomponent></cfcomponent>)
5. Add another factory method in root/Factory.cfc:
<cffunction name="createTests" access="public" returntype="Test2[]">
<cfreturn [new Test2(), new Test2()]>
</cffunction>
6. Run index.cfm
Actual Result:
coldfusion.runtime.TypedCollectionUtil$TypedArrayInvalidDataTypeException: Test2 is not a valid type.
at coldfusion.tagext.validation.CFTypedArrayValidator.validateWithType(CFTypedArrayValidator.java:73)
at coldfusion.runtime.UDFMethod.validateValueType(UDFMethod.java:210)
at coldfusion.runtime.UDFMethod.access$000(UDFMethod.java:52)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:504)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:447)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:398)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:371)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:287)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:818)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:601)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:426)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3380)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3357)
at cfindex2ecfm124667717.runPage(D:\inetpub\wwwroot\@users\...\migration_tests\bugs_and_breaking\typed_array_validation\invalid_cfc_type\index.cfm:3)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:262)
at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:729)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:565)
Expected Result: No error should be thrown.
Any Workarounds: Using the relative path in the returntype always seems to work: `returntype="nested.Test2[]"` instead of `returntype="Test2[]"`. Note that using `new Test2()` still works without the relative path which hints that the CFTypedArrayValidator seems to perform component resolution differently than the `new` operator and that it's implementation is most likely broken.
Attachments:
Comments: