tracker issue : CF-3971871

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

java.lang.ClassCastException when looping over query and returning a structure in a try block

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bryan Henderson / Bryan Henderson (Bryan Henderson)

Created: 04/17/2015

Components: Language, CF Component

Versions: 11.0

Failure Type: Crash

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / All users will encounter

Locale/System: ALL / Windows 7 64-bit

Vote Count: 2

Listed in the version 2016.0.03.300466 Issues Fixed doc
Problem Description:

A component defined as follows:
<cfcomponent>
	<cffunction name="foo">
		<cftry>
			<cfloop query="#QueryNew('one')#">
			</cfloop>
			<cfcatch>
				<cfreturn bar(a={b = 0}) />
			</cfcatch>
		</cftry>
	</cffunction>
</cfcomponent>

will cause a java.lang.ClassCastException when instantiated with createObject function or cfobject tag.

Steps to Reproduce:
create a component as defined above named "test.cfc".
in another file, instantiate an instance of the test component:
<cfobject component="test" name="test" />

Actual Result:
runtime exception:
{
  Message = "",
  StackTrace = "java.lang.ClassCastException",
  Suppressed = [],
  TagContext = [],
  Type = "java.lang.ClassCastException"
}

Expected Result:

continued program execution

Any Workarounds:

Do not use a try block
OR
do not pass a structure the the function in the cfreturn tag
OR
use cfoutput instead of cfquery

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

Watson Bug ID:	3971871

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



CF 11,0,05,293506 on Windows 7 running on Dell Precision M6700

Attachments:

Comments:

under workarounds, the third option should read: use cfoutput instead of cfloop
Comment by External U.
7778 | April 17, 2015 12:12:58 PM GMT
the error above occurs on the second and subsequent executions. the first time this error occurs it is more detailed: message = coldfusion.compiler.ASTcfloop cannot be cast to coldfusion.compiler.ASTcftag StackTrace = java.lang.ClassCastException: coldfusion.compiler.ASTcfloop cannot be cast to coldfusion.compiler.ASTcftag at coldfusion.compiler.SemanticAnalyzer.preTransform(SemanticAnalyzer.java:48) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:21) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:82) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.NeoTranslator.parseAndTransform(NeoTranslator.java:456) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:391) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:160) at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch(TemplateClassLoader.java:461) at coldfusion.util.LruCache.get(LruCache.java:180) at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(TemplateClassLoader.java:387) at coldfusion.util.AbstractCache.fetch(AbstractCache.java:58) at coldfusion.util.SoftCache.get_statsOff(SoftCache.java:133) at coldfusion.util.SoftCache.get(SoftCache.java:81) at coldfusion.runtime.TemplateClassLoader.findClass(TemplateClassLoader.java:642) at coldfusion.runtime.RuntimeServiceImpl.getFile(RuntimeServiceImpl.java:923) at coldfusion.runtime.RuntimeServiceImpl.resolveTemplatePath(RuntimeServiceImpl.java:890) at coldfusion.runtime.TemplateProxyFactory.getResolvedFile(TemplateProxyFactory.java:1274) at coldfusion.runtime.TemplateProxyFactory.getTemplateFileHelper(TemplateProxyFactory.java:1582) at coldfusion.runtime.MetadataUtils.getComponentMetadata(MetadataUtils.java:110) at coldfusion.runtime.CfJspPage.GetComponentMetadata(CfJspPage.java:2936)
Comment by External U.
7779 | April 17, 2015 12:38:54 PM GMT
Attached the cfc file . Once you create an object of this cfc the above exception would be observed. Passing an inline struct to a function is the issue.
Comment by Suchika S.
7780 | April 27, 2015 05:40:46 AM GMT
very annoying bug you need to rewrite a lot if code if you used "cfloop query" often and you can't simply search/replace with "cfoutput query" because of nesting cfoutput problem
Vote by External U.
7781 | May 13, 2015 03:31:59 AM GMT
I experience this bug when I port a software running on CF 10 to CF 11. It does not simply work in the new version, though it does in the older.
Vote by External U.
7782 | November 27, 2015 04:03:17 PM GMT