Adobe Livedocs Error
Today I was trying to look something up on Adobe Live docs and I came across an interesting error. I am not posting this error in the wild to point fingers at people because believe me I am far from perfect. I think this is a perfect opportunity to look at a couple of things that might of prevented this error.
Before we get into a solution we need to look at the problem. So as I was browsing the live docs today I saw the following page displayed.

Without more information I can't be sure what's going on here but I can take a stab at it. The first issue is with locking application variables. The reason you want to lock variables is because in a multi threaded environment you can have the chance (albeit slim chance) of 2 threads attempting to do the same thing at one time. I used to see this code all the time (even in my own stuff).
I still see this code in onRequest methods of the application cfc which is a no no. The application component gives a great method for this, onApplicationStart. You might of already known that but what you might not of known is that this method is single threaded so you don't have to worry about locking your variables. It's important to remember though, if you call this method manually it is no longer single threaded (something to keep in mind).
The other problem is this page is dumping out an error to screen. This can be easily avoided but it's extra work and honestly I am guilty of it as well. I could explain error handling to you but there is no need to. Ray Camden has an excellent article on Adding error handling to your ColdFusion application that I highly recommend.
Again, I am not picking on Adobe because I am far from perfect but when errors like this come up its always a good reminder to us what we can do to avoid them.
