diff --git a/jOOQ-test/src/org/jooq/test/_/testcases/DebuggerTests.java b/jOOQ-test/src/org/jooq/test/_/testcases/DebuggerTests.java index 93e124aaf3..2022b7f4e1 100644 --- a/jOOQ-test/src/org/jooq/test/_/testcases/DebuggerTests.java +++ b/jOOQ-test/src/org/jooq/test/_/testcases/DebuggerTests.java @@ -148,6 +148,8 @@ extends BaseTest RECURSION_LOCK = new ThreadLocal(); - static final ThreadLocal BREAKPOINT_EXECUTORS = new ThreadLocal(); + private static final ThreadLocal RECURSION_LOCK = new ThreadLocal(); + static final ThreadLocal BREAKPOINT_EXECUTORS = new ThreadLocal(); - private boolean hasDebuggers; + private boolean hasDebuggers; - private long startPrepareTime; - private long endPrepareTime; + private long startPrepareTime; + private long endPrepareTime; - private long startBindTime; - private long endBindTime; + private long startBindTime; + private long endBindTime; - private long startExecuteTime; - private long endExecuteTime; + private long startExecuteTime; + private long endExecuteTime; - private long startFetchTime; - private long endFetchTime; + private long startFetchTime; + private long endFetchTime; - private List matchers; - private QueryLog log; + private List matchers; + private QueryLog log; @Override public void start(ExecuteContext ctx) { @@ -111,8 +117,8 @@ public class DebugListener extends DefaultExecuteListener { startExecuteTime = 0; endExecuteTime = 0; - // Avoid recursion for processors and breakpoints. - recursionSafe(new Runnable() { + // Avoid recursion for processors. + recursionSafe(PROCESSOR_BEFORE, new Runnable() { @Override public void run() { Factory create = create(ctx); @@ -126,11 +132,15 @@ public class DebugListener extends DefaultExecuteListener { } } } + } + }); - // Process breakpoints + // Avoid recursion for breakpoints. + recursionSafe(BREAKPOINT_BEFORE, new Runnable() { + @Override + public void run() { breakpoints(true, ctx); } - }); } @@ -182,8 +192,8 @@ public class DebugListener extends DefaultExecuteListener { } } - // Avoid recursion for processors and breakpoints. - recursionSafe(new Runnable() { + // Avoid recursion for processors. + recursionSafe(PROCESSOR_AFTER, new Runnable() { @Override public void run() { Factory create = create(ctx); @@ -196,8 +206,14 @@ public class DebugListener extends DefaultExecuteListener { } } } + } + }); - // Process breakpoints + + // Avoid recursion for breakpoints. + recursionSafe(BREAKPOINT_AFTER, new Runnable() { + @Override + public void run() { breakpoints(false, ctx); } }); @@ -298,9 +314,9 @@ public class DebugListener extends DefaultExecuteListener { } } - private void recursionSafe(Runnable runnable) { + private void recursionSafe(QueryOrigin origin, Runnable runnable) { if (RECURSION_LOCK.get() == null) { - RECURSION_LOCK.set(new Object()); + RECURSION_LOCK.set(origin); try { runnable.run(); @@ -328,9 +344,12 @@ public class DebugListener extends DefaultExecuteListener { } private QueryLog getLog(ExecuteContext ctx) { + QueryOrigin origin = defaultIfNull(RECURSION_LOCK.get(), APPLICATION); + if (log == null) { log = new QueryLog( ctx.query(), + origin, endPrepareTime - startPrepareTime, endBindTime - startBindTime, endExecuteTime - startExecuteTime