[sonar] code bug

This commit is contained in:
zhongchao
2023-10-19 16:28:13 +08:00
parent 195f971425
commit 2a3e01f66e
44 changed files with 392 additions and 2756 deletions

View File

@@ -13,13 +13,17 @@ public class CollectionUtils {
OkHttpClient okHttpClient = OkHttpFactory.Companion.getOkHttpClient();
List<Interceptor> interceptors = okHttpClient.interceptors();
Field pro = getDeclaredField(interceptors, "list");
pro.setAccessible(true);
List<Interceptor> modifyerList = null;
try {
modifyerList = (List<Interceptor>) pro.get(interceptors);
modifyerList.add(new SimpleInterceptor());
} catch (IllegalAccessException e) {
e.printStackTrace();
if(pro != null){
pro.setAccessible(true);
List<Interceptor> modifierList;
try {
modifierList = (List<Interceptor>) pro.get(interceptors);
if(modifierList != null){
modifierList.add(new SimpleInterceptor());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
/**
@@ -32,7 +36,10 @@ public class CollectionUtils {
* @since2019年2月26日 下午4:06:16
*/
public static Field getDeclaredField(Object object, String fieldName){
Field field = null ;
if(fieldName == null){
return null;
}
Field field;
Class<?> clazz = object.getClass() ;
for(; clazz != Object.class ; clazz = clazz.getSuperclass()) {
try {