[sonar] code bug
This commit is contained in:
@@ -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 {
|
||||
* @since:2019年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 {
|
||||
|
||||
Reference in New Issue
Block a user