Skip to main content

Crash course in bug handling

Posted by kirillcool on November 17, 2005 at 5:55 AM PST
public class Developer {
   public void fixBugs(Set<Bug> bugs) {
      if ((bugs == null) || (bugs.size() == 0)) {
         // does this ever happen?
         throw new UnsupportedException();
      }
      if (bugs.size() > 10) {
         // unsupported
         throw new UnsupportedException("Too many bugs");
         // most probably was ignored, give another chance
         throw new IllegalArgumentException("Too many bugs");
         // most probably was ignored, nuke the bastards
         Thread.currentThread().destroy();
      }
     
      // start handling
      for (Bug bug : bugs) {
         // wait for a while, hoping it will fix itself
         Thread.sleep(10000);
         if (!bug.isActive()) {
            // that was nice
            continue;
         }
         // let's hope somebody else will take it
         Thread.yield();
         if (!bug.isActive()) {
            // what a sucker
            continue;
         }
         // come on!!! it's still active??? wtf???
         String filename = bug.getFilename();
         int tries = 0;
         while (bug.isActive() && (tries <= 10)) {
            RandomAccessFile raf = new RandomAccessFile(filename);
            // pick random file portion and change it
            raf.seek(Math.random()*raf.size());
            raf.write(" // fix for bug " + bug.getID() + " by @author\n");
            String[] keywords = {"for", "while", "do", "continue", "return", "null"};
            for (int i=0; i<100; i++) {
               raf.write(keywords[Math.random()*keywords.length]);
            }
            tries++;
         }
        
         // most probably it's a misinterpreted feature.
         if (Documentation.indexOf(bug.getDescription()) >= 0) {
            // lazy testers... with so much time on their hands why don't
            // they just read documentation?
            bug.close();
            continue;
         }
        
         // it *should* be a feature
         Designer designer = this.getProject().getLeadDesigner();
         if (designer.acceptsAsFeature(bug.getDescription())) {
            // sucker!!! lol rotfl 0wned!!!
            bug.close();
            continue;
         }
        
         // omg, must be a real bug
         Set<Bug> delegatedBugSet = new HashSet<Bug>();
         delegatedBugSet.add(bug);
         Developer guru = Developer.fetchGuru();
         if (this == guru) {
            // damn!
            throw new UnsupportedException("Will be fixed in service pack");
         }
         guru.fixBugs(delegatedBugSet);
      }
   
      // TODO write tests
      // TODO write documentation
      // TODO update bug tracking system
  
      // seems all is done.
   }
}