I'm currently parsing a number of xml files. In attempt to speed up processing
I'm running each file in its own parse thread (may be relevant, I'm not sure).
Inside of each I have a loop that is causing the error
java.lang.IndexOutOfBoundsException.
How can that statement with 'i' be throwing a
java.lang.IndexOutOfBoundsException when I just set 'i' to
increment from 1 to the length of xmlChildren?
Since you mentioned threads, are all of the variables properly scoped?
Assuming the array has not changed, it sounds like you might be
If stcXml.country.cities.xmlChildren is empty, then the first pass at
index=1 would be invalid. Can you verify that the the XML has at least 1
cities child?
~|
Want to reach the ColdFusion community with something they
If stcXml.country.cities.xmlChildren is empty, then the
first pass at index=1 would be invalid. Can you verify that the
the XML has at least 1 cities child?
Duh! Good point ;-)
-Leigh
~|
Want to reach the
If stcXml.country.cities.xmlChildren is empty, then the first pass at
index=1 would be invalid. Can you verify that the the XML has at least 1
cities child?
I do need to verify it, but if stcXml.country.cities.xmlChildren was empty
wouldn't the cfloop be equivalent to:
cfloop index=i from=1
Did you add some debugging? What is the value of i and the array length
XMLChildren when the error occurs?
__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
@Matthew,
Good call on the from=1 to=0 ... you're right that it wouldn't execute
at all ... hm
~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Did you add some debugging? What is the value of i and the array
length XMLChildren when the error occurs?
So the bizarre thing is a test page, like below, does not process the contents
of the loop:
Hello - Startbr /
cfloop index=i from=1 to=0
Howdy-Do Dah! cfoutput#i#/cfoutputbr /
Sounds like it may just be trying to load the entire 187 MB into memory and
choking on that? Perhaps overall memory usage is the real issue and the
OutOfBounds message is only a false report of a problem related to empty
memory spaces. Good luck debugging that!
However, changing the previous code example to:
cfif
ArrayLen(stcXml.country.cities.xmlChildren) gt 0
...
appears to fix the problem. all I can say is wtf?
Weird. That is like saying zero does not equal 0 anymore. Maybe there is
something special about the XMLChildren array?
Ah, Leigh may be on to it:
If the XML is blank or even if just the 'country' element is empty, than 0 is
still 0, but 0 can't be determined, since 'cities' wouldn't even exist in the
arrayLen(stcXml.country.cities.xmlChildren) test is 'country' is empty. That
would be why your new first test
Sounds like it may just be trying to load the entire 187 MB into memory
No. My initial approach was to attempt to load the entire file. Obviously, that
would consume a lot of memory and cause problems. Instead, I'm using the
cfloop file= process to load one line of xml into memory at a time
But before you can use CFLOOP the file had to be read into memory ...
something had to be there for CFLOOP to take action *on* ...
Matthew Reinbold wrote:
Sounds like it may just be trying to load the entire 187 MB into memory
No. My initial approach was to attempt to load the entire
Well, that clinches it. The *exact* same code with the threading pulled out (so
now the xml files are processed sequentially, not parallel) and the memory
problems disappear (the crude method of watching the memory allocation in
windows task manager shows a slight uptick, but no where near to
But before you can use CFLOOP the file had to be read into memory ...
No, that is not how the cfloop file= row= / tag works. Using that syntax
a person processes one line at a time. See this post (under Step 3 main
header starting with 1. Reading Lines):
... On a whim I also pulled out the extra check for the
xmlChildren size. Guess what? The unexplainable indexing
error is gone now too.
If you can consistently reproduce it, I would consider reporting it as a bug.
16 matches
Mail list logo