collection issues #1983

pull/2150/head^2
XenoAmess 3 years ago committed by hengyunabc
parent 6f8d38f9f5
commit 9c24d9da03

@ -2,7 +2,7 @@ package com.taobao.arthas.core.command.basic1000;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.alibaba.arthas.deps.org.slf4j.Logger;
@ -77,7 +77,7 @@ public class VMOptionCommand extends AnnotatedCommand {
process.end(-1, "In order to change the system properties, you must specify the property value.");
return;
} else {
process.appendResult(new VMOptionModel(Arrays.asList(option)));
process.appendResult(new VMOptionModel(Collections.singletonList(option)));
}
} else {
VMOption vmOption = hotSpotDiagnosticMXBean.getVMOption(name);

@ -12,7 +12,7 @@ import com.taobao.arthas.core.shell.command.CommandProcess;
import com.taobao.arthas.core.util.LogUtil;
import com.taobao.arthas.core.util.ThreadLocalWatch;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
/**
@ -90,7 +90,7 @@ public class TimeTunnelAdviceListener extends AdviceListenerAdapter {
TimeFragmentVO timeFragmentVO = TimeTunnelCommand.createTimeFragmentVO(index, timeTunnel);
TimeTunnelModel timeTunnelModel = new TimeTunnelModel()
.setTimeFragmentList(Arrays.asList(timeFragmentVO))
.setTimeFragmentList(Collections.singletonList(timeFragmentVO))
.setFirst(isFirst);
process.appendResult(timeTunnelModel);

@ -16,6 +16,7 @@
package com.taobao.arthas.core.env;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
@ -111,9 +112,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
@Override
public void setRequiredProperties(String... requiredProperties) {
for (String key : requiredProperties) {
this.requiredProperties.add(key);
}
this.requiredProperties.addAll(Arrays.asList(requiredProperties));
}
@Override

@ -8,6 +8,7 @@ import java.lang.instrument.UnmodifiableClassException;
import java.lang.reflect.Method;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -400,9 +401,7 @@ public class ArthasBootstrap {
if (configure.getDisabledCommands() != null) {
String[] strings = StringUtils.tokenizeToStringArray(configure.getDisabledCommands(), ",");
if (strings != null) {
for (String s : strings) {
disabledCommands.add(s);
}
disabledCommands.addAll(Arrays.asList(strings));
}
}
BuiltinCommandPack builtinCommands = new BuiltinCommandPack(disabledCommands);

@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
@ -671,17 +672,8 @@ public abstract class StringUtils {
}
public static Set<String> commaDelimitedListToSet(String str) {
TreeSet<String> set = new TreeSet<String>();
String[] tokens = commaDelimitedListToStringArray(str);
String[] var3 = tokens;
int var4 = tokens.length;
for(int var5 = 0; var5 < var4; ++var5) {
String token = var3[var5];
set.add(token);
}
return set;
return new TreeSet<String>(Arrays.asList(tokens));
}
/**

@ -7,6 +7,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@ -257,9 +258,7 @@ public class FieldUtils {
Class<?> currentClass = cls;
while (currentClass != null) {
final Field[] declaredFields = currentClass.getDeclaredFields();
for (final Field field : declaredFields) {
allFields.add(field);
}
allFields.addAll(Arrays.asList(declaredFields));
currentClass = currentClass.getSuperclass();
}
return allFields;

@ -586,23 +586,19 @@ public class ObjectView implements View {
appendStringBuilder(buf, format("@%s[%s]", className, obj));
} else {
appendStringBuilder(buf, format("@%s[", className));
List<Field> fields = new ArrayList<Field>();
final List<Field> fields;
Class<?> objClass = obj.getClass();
if (GlobalOptions.printParentFields) {
fields = new ArrayList<Field>();
// 当父类为null的时候说明到达了最上层的父类(Object类).
while (objClass != null) {
for (Field field : objClass.getDeclaredFields()) {
fields.add(field);
}
fields.addAll(Arrays.asList(objClass.getDeclaredFields()));
objClass = objClass.getSuperclass();
}
} else {
for (Field field : objClass.getDeclaredFields()) {
fields.add(field);
}
fields = new ArrayList<Field>(Arrays.asList(objClass.getDeclaredFields()));
}
if (null != fields) {
for (Field field : fields) {
field.setAccessible(true);
@ -628,7 +624,6 @@ public class ObjectView implements View {
}
}//for
appendStringBuilder(buf, "\n");
}//if
for (int i = 0; i < deep; i++) {
appendStringBuilder(buf, TAB);
}

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Loading…
Cancel
Save