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
Post a Comment