I use spring. I have many bundles with chaining dependency.
mvc bundle --> (calls) biz bundle --> core bundle --> common bundle --> remote RPC service
All bundles are loaded in the same JVM. But mvc bundle doesn't call biz bundle's object directly, instead biz bundle publishes the service by exposing an interface to mvc bundle. mvc bundle has a proxy object, and the proxy object calls the service implementation object.
my stacktrace looks like this:
...
at com.mycorp.kbdatacenter.common.service.integration.nomo.NomoDataServiceClientImpl.getPropertyDistribution(NomoDataServiceClientImpl.java:64) ~[kbdatacenter-common-service-integration-1.0.0.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_92]
at com.mycorp.sofa.runtime.service.binding.JvmBindingAdapter$JvmServiceInvoker$1.call(JvmBindingAdapter.java:87) ~[?:?]
at com.mycorp.ambush.chain.codewrapper.CodeWrapperInvocationImpl.proceed(CodeWrapperInvocationImpl.java:77) ~[ambush-1.0.10.jar:?]
at com.mycorp.guardian.client.sofa.GuardianCodeWrapperInterceptor.invokeCodeWrapper(GuardianCodeWrapperInterceptor.java:76) ~[guardian-sofa-1.1.5.jar:?]
at com.mycorp.ambush.chain.codewrapper.CodeWrapperInvocationImpl.proceed(CodeWrapperInvocationImpl.java:71) ~[ambush-1.0.10.jar:?]
at com.mycorp.ambush.catalog.AbstractCatalog.doIntercept(AbstractCatalog.java:252) ~[ambush-1.0.10.jar:?]
at com.mycorp.ambush.api.AmbushRPCUtil.invokeClient(AmbushRPCUtil.java:79) ~[ambush-1.0.10.jar:?]
at com.mycorp.sofa.runtime.service.binding.JvmBindingAdapter$JvmServiceInvoker.doInvoke(JvmBindingAdapter.java:90) ~[?:?]
at com.mycorp.sofa.runtime.service.component.ServiceProxy.invoke(ServiceProxy.java:29) ~[?:?]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at com.sun.proxy.$Proxy91.getPropertyDistribution(Unknown Source) ~[?:?]
at com.mycorp.kbdatacenter.core.service.tag.TagDataQueryServiceImpl.queryByFilterRule(TagDataQueryServiceImpl.java:105) ~[kbdatacenter-core-service-1.0.0.jar:?]
... (119 lines more)
My core bundle has a proxy object nomoDataServiceClient which calls Impl object in common bundle.
My question is, is it possible to filter StackTraceElement[], ignore packages com.sun.proxy, sun.reflect and others. I want my stackstace looks clean like this:
...
at com.mycorp.kbdatacenter.common.service.integration.nomo.NomoDataServiceClientImpl.getPropertyDistribution(NomoDataServiceClientImpl.java:64) ~[kbdatacenter-common-service-integration-1.0.0.jar:?]
at com.mycorp.kbdatacenter.core.service.tag.TagDataQueryServiceImpl.queryByFilterRule(TagDataQueryServiceImpl.java:105) ~[kbdatacenter-core-service-1.0.0.jar:?]
...
Yes you can. If you catch the exception, you could get the stack trace elements, create a new (filtered) array from it, and override the stacktrace of the exception, for example
try {
//your exception throwing call here
} catch(Exception e) {
e.setStackTrace(Arrays.stream(e.getStackTrace())
.filter(se -> !se.getClassName().startsWith("com.sun.proxy")) //or any other filter criteria
.collect(toList())
.toArray(new StackTraceElement[0])); //create a new stacktrace from the filtered list
//either e.printStackStrace();
//or rethrow
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With