一、前言
关于spring-context包org.springframework.remoting.support.RemoteInvocationUtils远程异常处理工具类,解析并收集异常集合信息进行处理,详情参见源码说明。
二、源码说明
package org.springframework.remoting.support;@b@@b@import java.util.HashSet;@b@import java.util.Set;@b@@b@public abstract class RemoteInvocationUtils@b@{@b@ public static void fillInClientStackTraceIfPossible(Throwable ex)@b@ {@b@ if (ex != null) {@b@ StackTraceElement[] clientStack = new Throwable().getStackTrace();@b@ Set visitedExceptions = new HashSet();@b@ Throwable exToUpdate = ex;@b@ while ((exToUpdate != null) && (!(visitedExceptions.contains(exToUpdate)))) {@b@ StackTraceElement[] serverStack = exToUpdate.getStackTrace();@b@ StackTraceElement[] combinedStack = new StackTraceElement[serverStack.length + clientStack.length];@b@ System.arraycopy(serverStack, 0, combinedStack, 0, serverStack.length);@b@ System.arraycopy(clientStack, 0, combinedStack, serverStack.length, clientStack.length);@b@ exToUpdate.setStackTrace(combinedStack);@b@ visitedExceptions.add(exToUpdate);@b@ exToUpdate = exToUpdate.getCause();@b@ }@b@ }@b@ }@b@}