Skip to content

Commit a963b47

Browse files
author
Alex Huang
committed
build better names
1 parent 251552f commit a963b47

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎utils/src/com/cloud/utils/db/Transaction.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,19 @@ protected static String buildName() {
258258
if (s_logger.isDebugEnabled()) {
259259
final StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
260260
final StringBuilder str = new StringBuilder();
261-
for (int i = 3, max = stacks.length > 7 ? 7 : stacks.length; i < max; i++) {
261+
int i = 3, j = 3;
262+
while (j < 7 && j < stacks.length) {
263+
StackTraceElement element = stacks[i];
264+
String filename = element.getFileName();
265+
String method = element.getMethodName();
266+
if ((filename != null && filename.equals("<generated>")) || (method != null && method.equals("invokeSuper"))) {
267+
i++;
268+
continue;
269+
}
270+
262271
str.append("-").append(stacks[i].getClassName().substring(stacks[i].getClassName().lastIndexOf(".") + 1)).append(".").append(stacks[i].getMethodName()).append(":").append(stacks[i].getLineNumber());
272+
j++;
273+
i++;
263274
}
264275
return str.toString();
265276
}

0 commit comments

Comments
 (0)