diff --git a/core/src/main/java/com/taobao/arthas/core/util/Decompiler.java b/core/src/main/java/com/taobao/arthas/core/util/Decompiler.java index e6837121f..993c2c339 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/Decompiler.java +++ b/core/src/main/java/com/taobao/arthas/core/util/Decompiler.java @@ -85,14 +85,16 @@ public class Decompiler { path = classFileSource.adjustInputPath(path); AnalysisType type = (AnalysisType) options.getOption(OptionsImpl.ANALYSE_AS); - if (type == null) + if (type == null) { type = dcCommonState.detectClsJar(path); + } if (type == AnalysisType.JAR) { // doJar(dcCommonState, path, dumperFactory); } - if (type == AnalysisType.CLASS) + if (type == AnalysisType.CLASS) { result.append(doClass(dcCommonState, path, skipInnerClass, dumperFactory)); + } } return result.toString(); } @@ -105,8 +107,9 @@ public class Decompiler { Dumper d = new ToStringDumper(); try { ClassFile c = dcCommonState.getClassFileMaybePath(path); - if ((skipInnerClass) && (c.isInnerClass())) + if ((skipInnerClass) && (c.isInnerClass())) { return ""; + } dcCommonState.configureWith(c); dumperFactory.getProgressDumper().analysingType(c.getClassType()); try { @@ -132,12 +135,14 @@ public class Decompiler { // collectingDumper.getTypeUsageInformation(), illegalIdentifierDump); String methname = (String) options.getOption(OptionsImpl.METHODNAME); - if (methname == null) + if (methname == null) { c.dump(d); + } else { try { - for (Method method : c.getMethodByName(methname)) + for (Method method : c.getMethodByName(methname)) { method.dump(d, true); + } } catch (NoSuchMethodException e) { throw new IllegalArgumentException("No such method '" + methname + "'."); } @@ -146,18 +151,21 @@ public class Decompiler { result.append(d.toString()); } catch (ConfusedCFRException e) { result.append(e.toString()).append("\n"); - for (Object x : e.getStackTrace()) + for (Object x : e.getStackTrace()) { result.append(x).append("\n"); + } } catch (CannotLoadClassException e) { result.append("Can't load the class specified:").append("\n"); result.append(e.toString()).append("\n"); } catch (RuntimeException e) { result.append(e.toString()).append("\n"); - for (Object x : e.getStackTrace()) + for (Object x : e.getStackTrace()) { result.append(x).append("\n"); + } } finally { - if (d != null) + if (d != null) { d.close(); + } } return result.toString(); } diff --git a/core/src/main/java/com/taobao/arthas/core/util/NetUtils.java b/core/src/main/java/com/taobao/arthas/core/util/NetUtils.java index 535b63bb7..f01a6055f 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/NetUtils.java +++ b/core/src/main/java/com/taobao/arthas/core/util/NetUtils.java @@ -191,12 +191,13 @@ public class NetUtils { } catch (Exception e) { return false; } finally { - if (s != null) + if (s != null) { try { s.close(); } catch (Exception e) { // ignore } + } } } 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 9774e41f8..bb028fa11 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 @@ -871,7 +871,9 @@ public abstract class StringUtils { } public static String classLoaderHash(Class clazz) { - if (clazz == null || clazz.getClassLoader() == null) return "null"; + if (clazz == null || clazz.getClassLoader() == null) { + return "null"; + } return Integer.toHexString(clazz.getClassLoader().hashCode()); } @@ -881,7 +883,9 @@ public abstract class StringUtils { * @return human readable format */ public static String humanReadableByteCount(long bytes) { - if (bytes < UNIT) return bytes + " B"; + if (bytes < UNIT) { + return bytes + " B"; + } int exp = (int) (Math.log(bytes) / Math.log(UNIT)); String pre = STRING_UNITS.charAt(exp-1) + "i"; return String.format("%.2f %sB", bytes / Math.pow(UNIT, exp), pre); diff --git a/core/src/main/java/com/taobao/arthas/core/view/Ansi.java b/core/src/main/java/com/taobao/arthas/core/view/Ansi.java index 91bc951d9..481b7d999 100644 --- a/core/src/main/java/com/taobao/arthas/core/view/Ansi.java +++ b/core/src/main/java/com/taobao/arthas/core/view/Ansi.java @@ -136,7 +136,9 @@ public class Ansi { }; public static void setDetector(final Callable detector) { - if (detector == null) throw new IllegalArgumentException(); + if (detector == null) { + throw new IllegalArgumentException(); + } Ansi.detector = detector; } @@ -698,8 +700,9 @@ public class Ansi { } private void flushAttributes() { - if (attributeOptions.isEmpty()) + if (attributeOptions.isEmpty()) { return; + } if (attributeOptions.size() == 1 && attributeOptions.get(0) == 0) { builder.append(FIRST_ESC_CHAR); builder.append(SECOND_ESC_CHAR);