[Anthill-pro] Avoid NPE's

Yanko, Curtis curt_yanko at uhc.com
Thu May 29 13:32:01 CDT 2008


 In  the spirit of Emerson here is a little idiom we have been rolling
out to protect our reports from NPE's

What is happening is that we periodically get buildlife that have no
endDate (aborted? Or running while the report is run!) so they'll break
the reports unless you check fro 'null' endDates or use a try/ catch
like we did. We capture the project and build life so we can spit it out
to the logs. We are also working on a clean up script to 'fix' endDates

for (int i = 0; i < summaries.length; i++) {
   projectname = summaries[i].getProjectName();
   buildlife = " "+summaries[i].getBuildLifeId();

   Calendar tempCal = Calendar.getInstance(timeZone);

 try {
    tempCal.setTime(summaries[i].getEndDate());
     } catch(NullPointerException npe) {
     System.out.println("Project / BL: "+projectname+" / "+buildlife);
     }

   boolean failed = (summaries[i].getStatus() ==
WorkflowStatusEnum.FAILED);

   if (failed) {
      hoursCountFailed[tempCal.get(Calendar.HOUR_OF_DAY)]++;
   }
   else {
      hoursCount[tempCal.get(Calendar.HOUR_OF_DAY)]++;
   }   
}


===
-Curt
W: 860.702.9059
M: 860.881.2050


This e-mail, including attachments, may include confidential and/or 
proprietary information, and may be used only by the person or entity to 
which it is addressed. If the reader of this e-mail is not the intended 
recipient or his or her authorized agent, the reader is hereby notified 
that any dissemination, distribution or copying of this e-mail is 
prohibited. If you have received this e-mail in error, please notify the 
sender by replying to this message and delete this e-mail immediately.



More information about the Anthill-pro mailing list