【发布时间】:2019-04-11 17:31:40
【问题描述】:
我有一个意外错误,它创建了 stackTrace,里面有很多行和不同的库。如果从上到下阅读它,可以看到除了 2-3 第一种方法之外的所有方法。好像
//Pseudo code
method1_1(){
method2();
}
method1_2(){
method2();
}
method1_3(){
method2();
}
method2(){
method3();
}
method3(){
method4();
}
method4(){
method5();
}
method5(){
method6();
}
StackTrace 仅显示 3-6 个方法,但没有显示第二个方法,第一个方法中的哪一个调用了第二个方法?我怎么知道?该程序很大,日志每 0,1-0,001 秒写入一次。这就是为什么记录每种方法都不好的原因。我无法为错误建模,它只会发生。我需要知道什么方法会引发该错误。示例中有 6 个第一种方法,但还有更多。
P.S.轨迹看起来像这样
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl.updateUser(UserDaoServiceImpl.java:418)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl$$FastClassBySpringCGLIB$$8732584e.invoke(<generated>)
INFO | 2019/04/11 14:23:20 | at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl$$EnhancerBySpringCGLIB$$c376b217.updateUser(<generated>)
INFO | 2019/04/11 14:23:20 | at sun.reflect.GeneratedMethodAccessor936.invoke(Unknown Source)
INFO | 2019/04/11 14:23:20 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | 2019/04/11 14:23:20 | at java.lang.reflect.Method.invoke(Method.java:498)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
INFO | 2019/04/11 14:23:20 | at com.sun.proxy.$Proxy564.updateUser(Unknown Source)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.Class2.method3(Class2.java:58)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.beans.Class3.method2(Class3.java:177)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.beans.Class3.lambda$method1$57(Class3.java:117)
INFO | 2019/04/11 14:23:20 | at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
INFO | 2019/04/11 14:23:20 | at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
INFO | 2019/04/11 14:23:20 | at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
INFO | 2019/04/11 14:23:20 | at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
com.company.smx.data.mobile.utils.beans.Class3.lambda$method1$57(Class3.java:117)这是伪代码的第三种方法,我需要知道第一种和第二种方法
UPD 我通过 REST API 调用我的第一个方法,所以它看起来像
public interface RestService {
@GET
@Produces("application/json; charset=utf-8")
@Path(value = "/rest/method1")
ResultResponse method1 (@PathParam("id") String id);
}
public class RestServiceImpl implements RestService {
method1_1(String id){
method2();
}
//and other pseudo code
}
正如我之前所说,在@Common Man 的帮助下,我可以找到直到第三种方法为止的唯一方法,因为在那之后我只有
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
【问题讨论】:
-
你能设置一个断点并逐步检查发生这种情况的地方吗?也许您也可以从中获得更多信息
-
不幸的是,我不能。它在任何地方都使用异步,例如 CompleteFuture、任何反射等,正如我所写的,第二个是很多日志。我猜不出什么时候会发生断点
-
您的堆栈跟踪完全没问题。
-
你为什么要删除你的答案?不应该尝试吗?如果我的跟踪很好,如何知道“第一个”方法中的哪个调用我第 3、第 4 等方法?
-
@Dred,我取消删除它,我在我的回答中提到了一个链接,值得一看。
标签: java stack-trace