Fix array out of bound bug in UnitOfWork purpose discovery logic.

This commit is contained in:
Greg Burd 2018-03-29 11:16:57 -04:00
parent 9d94e865b6
commit 6788cea1a0

View file

@ -131,14 +131,14 @@ public class UnitOfWork implements AutoCloseable {
StackTraceElement[] trace = Thread.currentThread().getStackTrace(); StackTraceElement[] trace = Thread.currentThread().getStackTrace();
String targetClassName = HelenusSession.class.getSimpleName(); String targetClassName = HelenusSession.class.getSimpleName();
String stackClassName = null; String stackClassName = null;
do { while (!stackClassName.equals(targetClassName) && frame < trace.length) {
frame++;
stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName()); stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName());
} while (!stackClassName.equals(targetClassName) && frame < trace.length);
do {
frame++; frame++;
}
while (stackClassName.equals(targetClassName) && frame < trace.length) {
stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName()); stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName());
} while (stackClassName.equals(targetClassName) && frame < trace.length); frame++;
}
if (frame < trace.length) { if (frame < trace.length) {
purpose = purpose =
new StringBuilder() new StringBuilder()