Commit f86b96f8 by 崔彦峰

fix(car-brand): 修复环境属性获取的空指针异常

- 在获取car.brand.list属性时添加默认值空字符串避免NPE
- 统一两处相同代码的属性获取方式以提高代码一致性
- 保持原有的业务逻辑不变仅修复潜在运行时错误
1 parent a71b1f66
...@@ -30,7 +30,7 @@ public class CarBrandService { ...@@ -30,7 +30,7 @@ public class CarBrandService {
private GopCarInfoRemote gopCarInfoRemote; private GopCarInfoRemote gopCarInfoRemote;
public CarBrandListResDTO getCarBrandList() { public CarBrandListResDTO getCarBrandList() {
log.info("获取车品牌列表:{}", env.getProperty("car.brand.list")); log.info("获取车品牌列表:{}", env.getProperty("car.brand.list",""));
String property = env.getProperty("car.brand.list"); String property = env.getProperty("car.brand.list");
List<CarBrandResDTO> carBrandResDTOS = JSON.parseArray(property, CarBrandResDTO.class); List<CarBrandResDTO> carBrandResDTOS = JSON.parseArray(property, CarBrandResDTO.class);
CarBrandListResDTO carBrandListResDTO = new CarBrandListResDTO(); CarBrandListResDTO carBrandListResDTO = new CarBrandListResDTO();
...@@ -40,7 +40,7 @@ public class CarBrandService { ...@@ -40,7 +40,7 @@ public class CarBrandService {
public CarSeriesListResDTO getCarSeriesList() { public CarSeriesListResDTO getCarSeriesList() {
log.info("获取车品牌列表:{}", env.getProperty("car.brand.list")); log.info("获取车品牌列表:{}", env.getProperty("car.brand.list", ""));
String property = env.getProperty("car.brand.list"); String property = env.getProperty("car.brand.list");
List<CarBrandResDTO> carBrandResDTOS = JSON.parseArray(property, CarBrandResDTO.class); List<CarBrandResDTO> carBrandResDTOS = JSON.parseArray(property, CarBrandResDTO.class);
if (carBrandResDTOS == null) { if (carBrandResDTOS == null) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!