hash - duplicate stack trace detection in java -


i trying find out hash function or utility code can used check if stack trace exists.

so, far using simple logic compare first 2000 characters , 2000 characters beginning caused part if exists.

this job however, more technical solution desired.

how like:

initialize:

stacktraceelement[] previous = null;     stacktraceelement[] current = null; 

assuming code starts somewhere in main:

    stacktraceelement[] stacktrace = thread.getcurrentthread().getstacktrace();     if( previous == null )     {        previous = stacktrace;     }     else if( current == null )     {        current = stacktrace;     }        if ( arrays.equals( current, previous ) )     {         duplicatestacktrace = true;     }       previous = current;     current = null; 

assuming built-in equals() function of stacktraceelement works you:

public boolean equals(object obj) {         if (obj==this)             return true;         if (!(obj instanceof stacktraceelement))             return false;         stacktraceelement e = (stacktraceelement)obj;         return e.declaringclass.equals(declaringclass) &&             e.linenumber == linenumber &&             objects.equals(methodname, e.methodname) &&             objects.equals(filename, e.filename);     } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -