Saturday, March 27, 2010

There's Three Hours of My Life I Won't Get Back

The next release of our product isn't slated to ship for months, but apparently our backlog of defects is getting important folks nervous. So the word was put out Friday (in a sort of passive-aggressive manner) that team members were expected to work the weekend (developers fixing bugs and testers verifying the fixes).

So I got up Saturday morning to work on a couple of bugs. Started at 8:00 AM and wanted to be done by noon or so. Was making good progress on this one defect, but when I went to test it, was having a hell of a time getting one of my new messages to render correctly. Our product runs on top of a framework written in Java and the messages use the Java MessageFormat class to substitute variables into the message.

From about 11:00 to 2:00, I could not get the damn message to format correctly. This is such a simple thing and I was really getting frustrated and pissed. In the framework the messages are stored in a database, so I was originally not sure if the message was being stored correctly in the database or if there was a cache issue where my message was not getting loaded because the message cache was stupid. 

Finally, around 2:30, I finally realized that I had mistyped a right paren instead of a right brace in the message text. {2) instead of {2}. Arghh. Once I realized my mistake, everything was good to go, but it was more than a little embarrassing to have wasted that much time on such an obvious mistake that I made. (First rule of debugging - never overlook the obvious and never assume your code is correct.)

But as Neil Peart once wrote, blame is better to give than receive....so my next mission was to look for a partner in crime. I was pretty sure that the MessageFormat class should have detected that unbalanced braces error and thrown an obvious exception. So I wrote a small driver program to test that and sure enough, it did just that. So now I was curious why I didn't see that exception when I was debugging my problem. If I would have seen that exception at 11:00 AM, I would have had my problem fixed at 11:01 instead of 2:30. 

So now this was personal!  So, for about the next 30 minutes, I was determined to find the culprit - the sloppy code in the framework that had just resulted in 3 hours of wasted effort. And sure enough I came across the following: 


public String getMessage(Object[] params)
{
  try
  {
  Message msg=new Message(getKey()+"="+value);
  return msg.getMessage(params);

  }
  catch(Exception e)
  {}    <<<<---Ah-hah!
  return getGroup()+"#"+getKey();
}

So a simple stupid 1 character typing error on my part wasted three hours of my time on a sunny Saturday in March because some gibrone was too lazy to log an exception and instead just ate it.

Man - when I saw that block of code, I was almost as angry as this kid.