1 16 17 package org.springframework.remoting.support; 18 19 import java.util.HashSet ; 20 import java.util.Set ; 21 22 import org.springframework.core.JdkVersion; 23 24 32 public abstract class RemoteInvocationUtils { 33 34 45 public static void fillInClientStackTraceIfPossible(Throwable ex) { 46 if (JdkVersion.isAtLeastJava14() && ex != null) { 47 StackTraceElement [] clientStack = new Throwable ().getStackTrace(); 48 Set visitedExceptions = new HashSet (); 49 Throwable exToUpdate = ex; 50 while (exToUpdate != null && !visitedExceptions.contains(exToUpdate)) { 51 StackTraceElement [] serverStack = exToUpdate.getStackTrace(); 52 StackTraceElement [] combinedStack = new StackTraceElement [serverStack.length + clientStack.length]; 53 System.arraycopy(serverStack, 0, combinedStack, 0, serverStack.length); 54 System.arraycopy(clientStack, 0, combinedStack, serverStack.length, clientStack.length); 55 exToUpdate.setStackTrace(combinedStack); 56 visitedExceptions.add(exToUpdate); 57 exToUpdate = exToUpdate.getCause(); 58 } 59 } 60 } 61 62 } 63 | Popular Tags |