Skip to content

Commit fec074c

Browse files
committed
! codeclimate: define and throw a dedicated exception instead of using a generic one #67
1 parent 28a6438 commit fec074c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

library/src/main/java/com/alibaba/dcm/agent/DcmAgent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.annotation.Nullable;
99
import java.io.*;
1010
import java.lang.instrument.Instrumentation;
11+
import java.lang.reflect.InvocationTargetException;
1112
import java.lang.reflect.Method;
1213
import java.text.SimpleDateFormat;
1314
import java.util.*;
@@ -79,7 +80,7 @@ public static void agentmain(@Nonnull String agentArgument) throws Exception {
7980
if (filePrinter != null) {
8081
try {
8182
filePrinter.close();
82-
} catch (Throwable e) {
83+
} catch (Exception e) {
8384
// do nothing!
8485
}
8586
}
@@ -164,7 +165,7 @@ private static boolean isDcmAgentSupressExceptionStack() {
164165
return "true".equalsIgnoreCase(supressException);
165166
}
166167

167-
private static Object invokeAction(String action, String[] arguments) throws Exception {
168+
private static Object invokeAction(String action, String[] arguments) throws InvocationTargetException, IllegalAccessException {
168169
Method method = action2Method.get(action);
169170

170171
final Class<?>[] parameterTypes = method.getParameterTypes();
@@ -248,7 +249,7 @@ private static void printDnsCacheEntry(DnsCacheEntry entry, PrintWriter writer)
248249
private static volatile Map<String, Method> action2Method;
249250
private static volatile ArrayList<String> actionList;
250251

251-
private static synchronized void initAction2Method() throws Exception {
252+
private static synchronized void initAction2Method() throws NoSuchMethodException {
252253
if (action2Method != null) return;
253254

254255
Map<String, Method> map = new LinkedHashMap<String, Method>();

tool/src/main/java/com/alibaba/dcm/tool/DcmTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class DcmTool {
2828

2929
private static final String DCM_AGENT_SUCCESS_MARK_LINE = "!!DCM SUCCESS!!";
3030

31-
private final static List<String> actionList = DcmAgent.getActionList();
31+
private static final List<String> actionList = DcmAgent.getActionList();
3232

3333
/**
3434
* entry main method.

0 commit comments

Comments
 (0)