Remove purpse guessing logic, it's overhead and buggy.

This commit is contained in:
Greg Burd 2018-03-29 11:57:43 -04:00
parent 6788cea1a0
commit 1f4c2154e2

View file

@ -50,8 +50,7 @@ import org.slf4j.LoggerFactory;
public class UnitOfWork implements AutoCloseable { public class UnitOfWork implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(UnitOfWork.class); private static final Logger LOG = LoggerFactory.getLogger(UnitOfWork.class);
private static final Pattern classNameRegex = private static final Pattern classNameRegex = Pattern.compile("^(?:\\w+\\.)+(?:(\\w+)|(\\w+)\\$.*)$");
Pattern.compile("^(?:\\w+\\.)+(?:(\\w+)|(\\w+)\\$.*)$");
public final UnitOfWork parent; public final UnitOfWork parent;
private final List<UnitOfWork> nested = new ArrayList<>(); private final List<UnitOfWork> nested = new ArrayList<>();
@ -122,37 +121,7 @@ public class UnitOfWork implements AutoCloseable {
}; };
} }
this.elapsedTime = Stopwatch.createUnstarted(); this.elapsedTime = Stopwatch.createUnstarted();
this.statementCache = this.statementCache = new MapCache<String, Object>(null, "UOW(" + hashCode() + ")", cacheLoader, true);
new MapCache<String, Object>(null, "UOW(" + hashCode() + ")", cacheLoader, true);
if (LOG.isInfoEnabled()) {
StringBuilder purpose = null;
int frame = 0;
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
String targetClassName = HelenusSession.class.getSimpleName();
String stackClassName = null;
while (!stackClassName.equals(targetClassName) && frame < trace.length) {
stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName());
frame++;
}
while (stackClassName.equals(targetClassName) && frame < trace.length) {
stackClassName = extractClassNameFromStackFrame(trace[frame].getClassName());
frame++;
}
if (frame < trace.length) {
purpose =
new StringBuilder()
.append(trace[frame].getClassName())
.append(".")
.append(trace[frame].getMethodName())
.append("(")
.append(trace[frame].getFileName())
.append(":")
.append(trace[frame].getLineNumber())
.append(")");
this.purpose = purpose.toString();
}
}
} }
public void addDatabaseTime(String name, Stopwatch amount) { public void addDatabaseTime(String name, Stopwatch amount) {