浏览代码

Update WxStorageController.java (#530)

解决litemallStorage有可能返回null值,会造成异常
zhanws 2 年之前
父节点
当前提交
9f81d58ce0

+ 2 - 2
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java

@@ -66,7 +66,7 @@ public class WxStorageController {
     @GetMapping("/fetch/{key:.+}")
     @GetMapping("/fetch/{key:.+}")
     public ResponseEntity<Resource> fetch(@PathVariable String key) {
     public ResponseEntity<Resource> fetch(@PathVariable String key) {
         LitemallStorage litemallStorage = litemallStorageService.findByKey(key);
         LitemallStorage litemallStorage = litemallStorageService.findByKey(key);
-        if (key == null) {
+        if (litemallStorage==null||key == null) {
             return ResponseEntity.notFound().build();
             return ResponseEntity.notFound().build();
         }
         }
         if (key.contains("../")) {
         if (key.contains("../")) {
@@ -91,7 +91,7 @@ public class WxStorageController {
     @GetMapping("/download/{key:.+}")
     @GetMapping("/download/{key:.+}")
     public ResponseEntity<Resource> download(@PathVariable String key) {
     public ResponseEntity<Resource> download(@PathVariable String key) {
         LitemallStorage litemallStorage = litemallStorageService.findByKey(key);
         LitemallStorage litemallStorage = litemallStorageService.findByKey(key);
-        if (key == null) {
+        if (litemallStorage==null||key == null) {
             return ResponseEntity.notFound().build();
             return ResponseEntity.notFound().build();
         }
         }
         if (key.contains("../")) {
         if (key.contains("../")) {