diff --git a/core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java b/core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java index fcc235209..739e45133 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/basic1000/VMOptionCommand.java @@ -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); diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelAdviceListener.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelAdviceListener.java index b5dead6a1..aad800ab9 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelAdviceListener.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TimeTunnelAdviceListener.java @@ -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); diff --git a/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java b/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java index 5ccda39c3..b9343ded0 100644 --- a/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java +++ b/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java @@ -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 diff --git a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java index 64546c197..407ca9a47 100644 --- a/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java +++ b/core/src/main/java/com/taobao/arthas/core/server/ArthasBootstrap.java @@ -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); diff --git a/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java b/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java index 3c73f2180..586c62657 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java +++ b/core/src/main/java/com/taobao/arthas/core/util/StringUtils.java @@ -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 commaDelimitedListToSet(String str) { - TreeSet set = new TreeSet(); 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(Arrays.asList(tokens)); } /** diff --git a/core/src/main/java/com/taobao/arthas/core/util/reflect/FieldUtils.java b/core/src/main/java/com/taobao/arthas/core/util/reflect/FieldUtils.java index f585e39b7..266b420af 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/reflect/FieldUtils.java +++ b/core/src/main/java/com/taobao/arthas/core/util/reflect/FieldUtils.java @@ -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; diff --git a/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java b/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java index 2c1429ca9..c170caf1d 100644 --- a/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java +++ b/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java @@ -586,49 +586,44 @@ public class ObjectView implements View { appendStringBuilder(buf, format("@%s[%s]", className, obj)); } else { appendStringBuilder(buf, format("@%s[", className)); - List fields = new ArrayList(); + final List fields; Class objClass = obj.getClass(); if (GlobalOptions.printParentFields) { + fields = new ArrayList(); // 当父类为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(Arrays.asList(objClass.getDeclaredFields())); } - if (null != fields) { - for (Field field : fields) { - - field.setAccessible(true); + for (Field field : fields) { - try { + field.setAccessible(true); - final Object value = field.get(obj); + try { - appendStringBuilder(buf, "\n"); - for (int i = 0; i < deep+1; i++) { - appendStringBuilder(buf, TAB); - } - appendStringBuilder(buf, field.getName()); - appendStringBuilder(buf, "="); - renderObject(value, deep + 1, expand, buf); - appendStringBuilder(buf, ","); + final Object value = field.get(obj); - } catch (ObjectTooLargeException t) { - buf.append("..."); - break; - } catch (Throwable t) { - // ignore + appendStringBuilder(buf, "\n"); + for (int i = 0; i < deep+1; i++) { + appendStringBuilder(buf, TAB); } - }//for - appendStringBuilder(buf, "\n"); - }//if + appendStringBuilder(buf, field.getName()); + appendStringBuilder(buf, "="); + renderObject(value, deep + 1, expand, buf); + appendStringBuilder(buf, ","); + + } catch (ObjectTooLargeException t) { + buf.append("..."); + break; + } catch (Throwable t) { + // ignore + } + }//for + appendStringBuilder(buf, "\n"); for (int i = 0; i < deep; i++) { appendStringBuilder(buf, TAB); } diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/cluster/RedisTunnelClusterStore.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/cluster/RedisTunnelClusterStore.java index 928b8ec8f..7a932cc56 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/cluster/RedisTunnelClusterStore.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/cluster/RedisTunnelClusterStore.java @@ -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;