Yesterday, when I was messing around with my first ColdFusion 8 sFTP commands using CFFTP, I came across a strange timeout bug. Many tags in ColdFusion allows us to enter override Timeout values. These values are always entered as seconds:
To make the code more readable, I like to make the timeout value dynamic when it has to be large. So, rather than doing:
... I'll make it more obvious:
Timeout="#(60 * 5)#"
While this might seem silly, 60*5 actually gives the programmer much more information than the value 300. For starters, by seeing the value "60" first, it indicates that the Timeout value is in seconds (rather than milliseconds). Secondly, by seeing 60*5, no calculation is required to know that the Timeout is set to 5 minutes; no having to divide 300 by 60 to see how many minutes that works out to.
Clearly, it's a great way to define Timeout values, but that's not what we're here to discuss. When I started to code my CFFTP example, I employed the same Timeout style setting:
<!--- Open the connection, cache it using, "objConnection", and give it a large timeout. ---> <cfftp action="open" connection="objConnection" timeout="#(60 * 5)#" attributeCollection="#objFTPProperties#" /> <!--- Close the connection. ---> <cfftp action="close" connection="objConnection" />
Here, as in my explanation above, I am setting the Timeout dynamically to be 5 minutes. Unfortunately, when I run the code, ColdFusion throws the following error:
(class: cftest2ecfm2015631588, method: runPage signature: ()Ljava/lang/Object;) Expecting to find object/array on stack null. The error occurred on line -1. java.lang.VerifyError: (class: cftest2ecfm2015631588, method: runPage signature: ()Ljava/lang/Object;) Expecting to find object/array on stack.
Well, obviously, right :) Talk about a ColdFusion error that give you zero insight into what actually went wrong.
Anyway, when I took out the dynamic Timeout value and put in a static "300," the page worked fine. Clearly a bug (that I have reported).
Want to use code from this post? Check out the license.
What happens if you assign 60 * 5 to a variable, and then plug the variable into the attribute?
That seems to be CF generating an inconsistent class file. Something in the compiler is doing something naughty.
You should report this to Adobe, Definitely a bug!
I'm slow... I see that you have reported it. Woops. My bad.
I did not try to do it as a variable. I just resorted to putting in the full time rather than the calculation.
Naughtiness reported :) Weird looking error, right?
Interesting finding! I wonder if it's just the calculation it has to do for the timeout value or if it's any variable at all.
A little late, but this worked for other tags that gave the dynamic error...
I haven't tried it the cfftp timeout yet, but I think #int(60 * 5)# should work just fine...
If you test it, let us know if it works (I don't have any FTP stuff set up for testing at the moment).
Yessss Works like a charm!
<cfftp action = "open"
username = "Foo"
connection = "connection1"
password = "nonono"
server = "ftp.somethi.ng"
stopOnError = "Yes" timeout="#int(60 * 5)#">
Very odd! I wonder why that works. Good to know - thanks for running the test.