第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Java - 非空參數(shù)的聲納空傳遞

Java - 非空參數(shù)的聲納空傳遞

紫衣仙女 2023-08-04 19:09:21
Sonar 在第 17 行標記此后映射,并顯示以下錯誤(Date parsedStartDate = df.parse(startDate);)://Magicservice.controller.MagicStoreController.getTradeMagicsByDateRange(HttpServletRequest, String, String, String) 中java.text.DateFormat.parse(String)的非空參數(shù)傳遞Null //此方法調(diào)用為非空參數(shù)傳遞空值方法參數(shù)為空。要么該參數(shù)被注釋為應(yīng)始終為非空的參數(shù),要么分析表明它將始終被取消引用。該代碼已經(jīng)阻止傳遞空值,不確定這里是否缺少某些內(nèi)容@PostMapping(value = "/Magics/MagiclistbyDateRange/{MagicStatus}")    public @ResponseBody List<MagicLog> getTradeMagicsByDateRange(HttpServletRequest request,            @PathVariable String MagicStatus, @RequestParam(value = "STARTDATE", required =false ) String startDate,@RequestParam(value = "ENDDATE", required =false) String endDate)            throws ESException {        logger.info("MagicLog received from client -  MagicStatus is :: " + MagicStatus);        String inAppAuthorization = request.getHeader("InAppAuthorization");        validateRequest(request, inAppAuthorization);        List<MagicLog> MagicLogs = new ArrayList<>();        DateFormat df = new SimpleDateFormat("yyyyMMddHH:mm:ss");        df.setLenient(false);        if (startDate == null && endDate==null) {            throw new ESException(MSG_ERROR_NULL_INPUTS);        }        else{        try {            // THIS is the line causing issues (17)            Date parsedStartDate = df.parse(startDate);            //Null passed for non-null parameter of java.text.DateFormat.parse(String) in Magicservice.controller.MagicStoreController.getTradeMagicsByDateRange(HttpServletRequest, String, String, String)            //This method call passes a null value for a non-null method parameter. Either the parameter is annotated as a parameter that should always be non-null, or analysis has shown that it will always be dereferenced.
查看完整描述

1 回答

?
慕哥9229398

TA貢獻1877條經(jīng)驗 獲得超6個贊

startDate您只處理當和endDate均為空時的情況
相反,您應(yīng)該處理其中任何一個為空時的情況:

if (startDate == null || endDate==null) { 
           throw new ESException(MSG_ERROR_NULL_INPUTS);
        }


查看完整回答
反對 回復(fù) 2023-08-04
  • 1 回答
  • 0 關(guān)注
  • 248 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號