Dan J.

Full-stack VC and Big Picture Thinker. Certified MUMPS Guru. Better than Lyle.

Sep 2014

Failure to Leap

by in CodeSOD on

When you're a developer like Joe, and your clients all have dedicated servers, and they all call at the same time to complain that their servers have gone down, you can't help but start hoping there was an earthquake. Unless the data center housing all that dedicated hardware was wiped off the face of the earth, the bug was going to be in your software. And sure enough, in the midst of the legacy C++ module responsible for processing the day's transactions, Joe found this:

bool done = false;
while(!done)
{
    try
    {
        //I'm not sure if having a log entry for the irregular
        //Febuary[sic] 29th will destroy everything else.
        //To be on the safe side, we'll just wait 'til tomorrow instead
        Date *currentDate = new Date();
        int DOY = currentDate->dayOfYear();
        if( DOY == 60 && //day 60 is feb 29
            ( lastDigit(currentDate->year()) == 0 ||
              lastDigit(currentDate->year()) == 4 ||
              lastDigit(currentDate->year()) == 8))
        {
            while(currentDate->dayOfYear() == 60) { currentDate = new Date(); }
        }
        else
        {
            //SNIP: code that actually runs part of the maintenance
            done = true;
        }
    }
    catch(...) {} //If we failed we need to try again until we succeed
}