【fix sonar】RestUtil文件
This commit is contained in:
+9
-6
@@ -1,6 +1,7 @@
|
||||
package com.jero.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.*;
|
||||
@@ -20,6 +21,10 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class RestUtil {
|
||||
|
||||
private RestUtil(){
|
||||
|
||||
}
|
||||
|
||||
private static String domain = null;
|
||||
|
||||
public static String getDomain() {
|
||||
@@ -188,10 +193,10 @@ public class RestUtil {
|
||||
public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
|
||||
log.info(" RestUtil --- request --- url = "+ url);
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
throw new RuntimeException("url 不能为空");
|
||||
throw new JeroBootException("url 不能为空");
|
||||
}
|
||||
if (method == null) {
|
||||
throw new RuntimeException("method 不能为空");
|
||||
throw new JeroBootException("method 不能为空");
|
||||
}
|
||||
if (headers == null) {
|
||||
headers = new HttpHeaders();
|
||||
@@ -243,10 +248,8 @@ public class RestUtil {
|
||||
String key = it.next();
|
||||
String value = "";
|
||||
Object object = source.get(key);
|
||||
if (object != null) {
|
||||
if (!StringUtils.isEmpty(object.toString())) {
|
||||
value = object.toString();
|
||||
}
|
||||
if (object != null && !StringUtils.isEmpty(object.toString())) {
|
||||
value = object.toString();
|
||||
}
|
||||
urlVariables.append("&").append(key).append("=").append(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user