修復線上問題,引起新的bug-總結
由於沒有對新引入的引數Long actShopId, String shopProdId 做非空判斷,就直接拼接,導致拼接的請求url報404錯誤
修復前:
@RequestMapping(value = "/virtual/views/{prod}")
public String viewsIndex(HttpServletRequest request, HttpServletResponse response, @PathVariable("prod") String prod, Long actShopId, String shopProdId) {
return "redirect:/views/" + prod + "?actShopId=" + actShopId + "&shopProdId=" + shopProdId;
}
當引數為空時,得出的請求url為:
修復後:
@RequestMapping(value = "/virtual/views/{prod}")
public String viewsIndex(HttpServletRequest request, HttpServletResponse response, @PathVariable("prod") String prod, Long actShopId, String shopProdId) {
if(AppUtils.isNotBlank(actShopId)&&AppUtils.isNotBlank(shopProdId)){
return "redirect:/views/" + prod + "?actShopId=" + actShopId + "&shopProdId=" + shopProdId;
}
return "redirect:/views/" + prod;
}
總結:修復線上問題的時候,儘量考慮到介面不影響到之前的操作,即是所謂的向上相容。
可以列出我們修復後接口可能出現的情況。然後去分別除錯我們的介面。