Skip to content

Fix @ProfileConnection stack depth showing filtered and null frames - #289

Merged
jeanbisutti merged 1 commit into
quick-perf:masterfrom
jeanbisutti:fix-profile-connection-stack-depth
Oct 19, 2026
Merged

jeanbisutti merged 1 commit into
quick-perf:masterfrom
jeanbisutti:fix-profile-connection-stack-depth

Conversation

@jeanbisutti

Copy link
Copy Markdown
Collaborator

Problem

With @ProfileConnection(displayStackTrace = true, stackDepth = N), the stack traces could show frames that the stack trace filters had removed, and null lines.

For example, a JUnit 5 test with stackDepth = 10 printed this for prepareStatement (JDK 17, connection id replaced):

connection id - java.sql.Connection.prepareStatement(String sql) [sql: select isbn from Book]
	org.quickperf.sql.TmpStackDepthJUnit5Test$C_D10.test(TmpStackDepthJUnit5Test.java:157)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:568)
	org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	org.quickperf.junit5.QuickPerfTestExtension.executeTestMethodAndRecordPerformanceInSameJvm(QuickPerfTestExtension.java:270)
	org.quickperf.junit5.QuickPerfTestExtension.executeTestMethodAndRecordPerformance(QuickPerfTestExtension.java:238)

With the fix, it prints only the test method frame, as with the default depth:

connection id - java.sql.Connection.prepareStatement(String sql) [sql: select isbn from Book]
	org.quickperf.sql.TmpStackDepthJUnit5Test$C_D10.test(TmpStackDepthJUnit5Test.java:157)

With stackDepth = 143 in the same test, the getConnection() stack trace showed the 7 expected frames, then 132 JDK reflection, JUnit, QuickPerf extension and Surefire frames, then 4 null lines.

Cause

StackTrace.formatWith first applies the filters, which compute the range of elements to keep:

  • QuickPerfStackTraceTraceFilter moves the start past the QuickPerf frames.
  • The JUnit 4, JUnit 5, and TestNG filters move the end to the last frame before the framework calls the test method by reflection.

limitTo then applied the stack depth.

@jeanbisutti
jeanbisutti merged commit 3386635 into quick-perf:master Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant