Article 2QJKB CodeSOD: Lucee Execution

CodeSOD: Lucee Execution

by
Jane Bailey
from The Daily WTF on (#2QJKB)

512px-I_Love_Lucy_title.svg.png

Recently, at my dayjob, I had a burning need to understand how scheduled tasks work. You see, we've recently switched from Adobe Coldfusion to Lucee, and I was shaky on how Adobe did things before, so I wanted a deeper understanding of how the code I was working on would be executed. For the uninitiated, Lucee is an open-source reimplementation of Cold Fusion. And that's not the WTF.

It's open source, I thought to myself. I'll just take a look at the code.

I had one problem. Then I looked at the code. Now I have two problems ... and a headache:

private long calculateNextExecution(long now, boolean notNow) {long nowTime=util.getMilliSecondsInDay(timeZone,now);long nowDate=now-nowTime;// when second or date intervall switch to current dateif(startDate<nowDate && (cIntervall==Calendar.SECOND || cIntervall==Calendar.DATE))startDate=nowDate;// init calendarCalendar calendar = JREDateTimeUtil.getThreadCalendar(timeZone);calendar.setTimeInMillis(startDate+startTime);long time;while(true) {time=getMilliSecondsInDay(calendar);if(nowendTime)now=nowDate+DAY;else break;}calendar.add(cIntervall, amount);}return calendar.getTimeInMillis();}

"So okay, if now is before or starting at-hang on, what's calendar again?" I found myself muttering aloud. "Okay, if now is before or equal to the start date plus the start time, and time-which, if I understand that method correctly, is the elapsed time in the current day-is after or equal to the start time ... when is that true exactly? You know what would be nice? Some #%#@$%@ Javadoc!"

This is only one representative method, and yet, there's just so much here. Why an if statement that does nothing, terminating in an easily-overlooked semicolon? Why the misspelling of EVERY? Or "Intervall?" Why are the programmers allergic to spaces? Why can't they name variables worth anything? Do I even really want to know how this works anymore?

If you want to witness the madness for yourself, may I remind you: this code is open source. Have at ye. According to the copyright statement at the top, this code was inherited from the Railo project, so if you're in Switzerland, please be sure to send your hate mail to the right address.

puppetlabs50.png[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today! TheDailyWtf?d=yIl2AUoC8zAZbZT6d9g7lU
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments