|
18 | 18 | */ |
19 | 19 | public class DcmAgent { |
20 | 20 | static final String FILE = "file"; |
| 21 | + static final String DCM_AGENT_SUPRESS_EXCEPTION_STACK = "DCM_AGENT_SUPRESS_EXCEPTION_STACK"; |
21 | 22 | static final String DCM_AGENT_SUCCESS_MARK_LINE = "!!DCM SUCCESS!!"; |
22 | 23 |
|
23 | 24 | public static void agentmain(String agentArgument) throws Exception { |
@@ -75,8 +76,14 @@ public static void agentmain(String agentArgument) throws Exception { |
75 | 76 | } catch (Exception e) { |
76 | 77 | allSuccess = false; |
77 | 78 | final String exString = throwable2StackString(e); |
| 79 | + final String sdtoutExString; |
| 80 | + if (isDcmAgentSupressExceptionStack()) { |
| 81 | + sdtoutExString = e.toString(); |
| 82 | + } else { |
| 83 | + sdtoutExString = exString; |
| 84 | + } |
78 | 85 |
|
79 | | - System.out.printf("%s: Error to do action %s %s, cause: %s%n", DcmAgent.class.getName(), action, argumentString, exString); |
| 86 | + System.out.printf("%s: Error to do action %s %s, cause: %s%n", DcmAgent.class.getName(), action, argumentString, sdtoutExString); |
80 | 87 | if (filePrinter != null) { |
81 | 88 | filePrinter.printf("Error to do action %s %s, cause: %s%n", action, argumentString, exString); |
82 | 89 | } |
@@ -186,6 +193,24 @@ static Object[] convertStringArray2Arguments(String action, String[] arguments, |
186 | 193 | return methodArgs; |
187 | 194 | } |
188 | 195 |
|
| 196 | + static boolean isDcmAgentSupressExceptionStack() { |
| 197 | + String supressException = getConfig(DCM_AGENT_SUPRESS_EXCEPTION_STACK); |
| 198 | + if (supressException == null) return false; |
| 199 | + |
| 200 | + supressException = supressException.trim(); |
| 201 | + if (supressException.length() == 0) return false; |
| 202 | + |
| 203 | + return "true".equalsIgnoreCase(supressException); |
| 204 | + } |
| 205 | + |
| 206 | + static String getConfig(String name) { |
| 207 | + String var = System.getenv(name); |
| 208 | + if (var == null || var.trim().length() == 0) { |
| 209 | + var = System.getProperty(name); |
| 210 | + } |
| 211 | + return var; |
| 212 | + } |
| 213 | + |
189 | 214 | static void printResult(String action, Object result, PrintWriter writer) { |
190 | 215 | if (writer == null) { |
191 | 216 | return; |
|
0 commit comments