执行非空检查时,我在以下代码中获得了“可能的空指针取消引用dssResponseStatus”。最初为dssResponseStatus分配了一个空值,但它已被用于从不同的方法获取状态。
我该如何解决这个问题。帮助人
DSSAdminResponseBean createIdAdminBean = new DSSAdminResponseBean();
String dssResponseStatus = null;
// To overcome cupcake overriding
userCupcakeValue = (String) request.getSession().getAttribute(
DSSAdminGuiConstants.USERCUPCAKE);
DSSADMINLogger.log(
DEBUG,
"userCupcakeValue :"
+ MaskingSecuredData
.maskingSecuredData(userCupcakeValue));
ArrayList createIdList = createIdService.getCreateIdManager(
createIdBean, userCupcakeValue);
dssResponseStatus = DSSCheckResponseStatus.toCheckResponseStatus(
createIdAdminBean, createIdList);
DSSADMINLogger.log(DEBUG, "dssResponseStatus :" + dssResponseStatus);
performAudit(request, createIdBean, dssResponseStatus);
// When the dssResponseStatus gets the error value as connectionError,
// then it will be forward to error Page
//getting the error in this line if (dssResponseStatus != null
&& !dssResponseStatus
.equals(DSSAdminGuiConstants.DSS_SUCCESS_STATUS)
&& !dssResponseStatus
.equalsIgnoreCase(DSSAdminGuiConstants.CONNECTION_ERROR)) {
String message = ErrorMessages.errorCodes(dssResponseStatus,
DSSAdminGuiConstants.CREATEID);
DSSADMINLogger.log(ERROR,
"DSSResponseServer ErrorStatus for CreateId API :"
+ message);
return new ModelAndView(DSSAdminGuiConstants.DSSADMINCREATEID,
DSSAdminGuiConstants.RESPONSE_ERROR, message);
} else if (dssResponseStatus
.equalsIgnoreCase(DSSAdminGuiConstants.CONNECTION_ERROR)) {
DSSADMINLogger.log(ERROR, "DSSResponseSerever ErrorStatus :"
+ dssResponseStatus);
return new ModelAndView(DSSAdminGuiConstants.DSSADMINERRORMESSAGE,
DSSAdminGuiConstants.ERROR_STATUS, 2);
} else {
DSSADMINLogger.log(INFO, "Leaving getCreateIdResponse Method");
return new ModelAndView(DSSAdminGuiConstants.DSSADMINGETID,
DSSAdminGuiConstants.CREATEID_ATTRIBUTES, createIdList);
}
}