zimi
zimi

Reputation: 1596

Duplicate stacktraces

I would like to do something like here: http://statistics.netbeans.org/analytics/detail.do?id=204003 for my application

Where netbeans team automatically know if the report they gets is some new bug or if it has duplicates.

Suppose I have exception as below.

Caused by: javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3894)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3794)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3596)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1379)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
    at com.sun.proxy.$Proxy99.getProjectsBySearchCriteria(Unknown Source)
                     ^
                     here is $Proxy99 I told about

    at my.project.crm.web.controllers.contacts.ContactDetailsController.updateUndeletedProjectCollection(ContactDetailsController.java:2666)
    at my.project.crm.web.controllers.contacts.ContactDetailsController.init(ContactDetailsController.java:489)
    ... 83 more
Caused by: java.lang.NullPointerException
    at my.project.utils.security.UserRights.(UserRights.java:182)
    at my.project.utils.security.AbstractSecurity.(AbstractSecurity.java:26)
    at my.project.utils.security.ProjectSecurity.(ProjectSecurity.java:138)
    at my.project.crm.enterprise.facades.projects.ProjectFacadeImpl.getProjectsBySearchCriteria(ProjectFacadeImpl.java:637)
    at sun.reflect.GeneratedMethodAccessor6373.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
    at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
    ... 87 more

I guess I could make some kind of signature with these few steps:

This way I get some kind of signature of bug in my application

Is there some easier way to do it?

Upvotes: 2

Views: 957

Answers (1)

André Stannek
André Stannek

Reputation: 7863

I don't know if this question can have a single correct answer but here are some thoughts about your points:

  • Don't remove any lines. Everything can be important
  • Don't remove the line numbers, even for an equality check. If you want to handle different versions, add the actual version to your report and sort out duplicates manually. You could use your a version without line numbers for detecting possible duplicates but I would always review it manually.
  • Those proxy names can be a problem if you want to compare stacktraces programatically. Renaming them would be a solution but be aware that two proxies with the same id still need to have the same name after renaming. It would need a complex parser to do that.
  • Always compare the whole stacktrace instead of just the hash value. Hash values are not collision free. Although a collision is not very propable, it could still happen that you misinterpret two different stacktraces as the same. If you worry about performance: That shouldn't be an issue in this case.

Finally I'd say take a look at the Java API for Throwable and Exception, espacially getStackTrace(). I'm not into it myself but maybe you can use it to edit and compare your stacktrace without having to do complex string magic.

Upvotes: 3

Related Questions