I have a batch job which processes data from source to destination. Once in a while I see NPE immediately after the job triggers and it runs fine until it finishes. Looks like line 96 is throwing the error but I am not sure why when the job triggers? This is the line which I think is the source f the error.
Node node = nodeList.item( 0 ).getAttributes().getNamedItem(DCDirectProcessorConstants.Tag_Response_Status);
Java Code
InputSource source = new InputSource();
source.setCharacterStream(new StringReader(response));
Document document = builder.parse(source);
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodeList = document.getElementsByTagName(DCDirectProcessorConstants.Tag_Response_getValue);
Node node = nodeList.item( 0 ).getAttributes().getNamedItem(DCDirectProcessorConstants.Tag_Response_Status);
RatingSessionTO responseTO = XMLProcessingUtil.processResponseData(
ratingSessionTO, response, migrationConfig, data.toString());
/*DataMigrationDao dao = null;
if( migrationConfig.isOneTimeMigration() ){
dao = (DataMigrationDao) appContext.getBean("oneTimeMigrationDao");
}else{
dao = (DataMigrationDao) appContext.getBean("dailyMigrationDao");
}
*/
//This flow is explicitly for Catchup
if("1".equals(catchUp)){
if(kafkaFailure){
postMessageToKafka(responseTO,catchUp,dao);
}
else if(raterFailure){
//Handle rater failure
int ID = dao.getExternalID(responseTO);
if(ID != 0){
responseTO.setExternalID(ID);
}
migrateMessageToRaterInfo(responseTO,dao,catchUp);
}
else{ //Handle XML_Sessions failure
try{
if(dao.verifySessionID(responseTO) == 0){
// Defect 76093
if (node == null || DCDirectProcessorConstants.Status_Failure.equalsIgnoreCase(node.getTextContent())) {
logger.error("Retry failure.Source id already present in catchup "+ ratingSessionTO.getSrcId());
} else {
dao.migrateData(responseTO);
postMessageToKafka(responseTO, catchUp, dao);
migrateMessageToRaterInfo(responseTO, dao, catchUp);
}
} else{
logger.error("Source id already present in archive "+ratingSessionTO.getSrcId()+" Updating status to 'C'");
dao.updateCatchupCompletion(ratingSessionTO.getSrcId());
}
}
catch(Exception e){
logger.error("Catchup failed for "+ratingSessionTO.getSrcId()+" Status remains 'P'");
}
}
}
Stack Trace
java.lang.NullPointerException
at com.mercuryinsurance.r3.util.MigrationExecutorThread.run(MigrationExecutorThread.java:96) [migration.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_66] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_66] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]