Skip to content
Permalink
Browse files

Add isCallingMe in the StackTraceUtils class (#197)

fix #196
  • Loading branch information...
darkman97i authored and monkiki committed Sep 9, 2019
1 parent 61261fa commit 39321cfb51a7bc12fb0c4a8466590cd855bd47ef
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/main/java/com/openkm/util/StackTraceUtils.java
@@ -83,6 +83,24 @@ public static String getTrace() {
return sb.toString();
}

/**
* Is this method or package calling me?
*/
public static boolean isCallingMe(String className) {
StackTraceElement[] trace = (new Throwable()).getStackTrace();

// Once you have the trace you can pick out information you need.
if (trace.length >= 2) {
for (int i = 2; i < trace.length; i++) {
if (trace[i].getClassName().startsWith(className)) {
return true;
}
}
}

return false;
}

/**
* Convert stack trace to String
*/

0 comments on commit 39321cf

Please sign in to comment.
You can’t perform that action at this time.