Reputation: 273
I'm getting an issue as "Error Occurred While Processing Request The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values."
I verified all posts related to NPException & most of the issues are related to cfquery, cfhttp......This issue is with in cfloop iteration in cfc function (Y) I have two functions X & Y. Y is called by X multiple times with in the loop. This loop is in cflock tag with timespan=5
function X :
============
<cfset Var array = getXML()>
<cfargument name="searchOnly" type="boolean" required="false">
<cfset Var i = "">
inside loop Y method is called
<cflock scope="Session" type="exclusive" timeout="5">
<cfloop from="1" to="#ArrayLen( array )#" index="i">
<cfset fields = Y( array[i], Arguments.searchOnly )>
</cfloop>
</cflock>
===========
function Y :
============
<cffunction name=“Y”>
<cfargument name="root" required="true">
<cfargument name="searchOnly" type="boolean" required="false">
<cfset Var i = "">
<cfloop index="i" from="1" to="#ArrayLen( Arguments.root.XMLChildren )#">
<cfset childNode = Arguments.root.XMLChildren[i]> ---> this line causes an error
<cfif Arguments.root.XMLName neq "match">
<!--- Recursive call --->
<cfset Y( labeledElements, Y( childNode ) )>
</cfif>
Is there any issue with Recursive call with in the same cfloop.
</cfloop>
</cffunction>
Variable i is declared in these two cffunctions, is this raising any issue with same variable name i. Please share your thoughts
Upvotes: 1
Views: 699
Reputation: 29870
You're not var
-ing childNode
, so you will be overwriting the outer call's variable with the recursive call's one. This will make the process unstable, and unsurprising that you get unexpected results / errors.
I imagine that's your problem.
Upvotes: 3