From 3ea9a5fa7f43698290747139c871d8879e645e18 Mon Sep 17 00:00:00 2001 From: "robin.bygrave" Date: Thu, 11 Jun 2026 20:28:10 +1200 Subject: [PATCH] Test: Fix DtoQueryPlanCaptureTest by draining plans --- .../ebean/xtest/base/DtoQueryPlanCaptureTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java index 225955e56..1bb2fc50c 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryPlanCaptureTest.java @@ -72,10 +72,22 @@ class DtoQueryPlanCaptureTest extends BaseTestCase { .findList(); } + private void drainCapturedPlans() { + QueryPlanRequest drain = new QueryPlanRequest(); + drain.maxCount(100_000); + drain.maxTimeMillis(30_000); + DB.getDefault().metaInfo().queryPlanCollectNow(drain); + } + @Test void nativeDtoQuery_capturesQueryPlan() { ResetBasicData.reset(); + // drain any query plans captured by earlier tests in the suite, otherwise the + // shared (process-global) capture map can exhaust the collect budget below before + // our plan is reached (order dependent, and slow to capture on Oracle). + drainCapturedPlans(); + // build the plans first (default threshold -> no capture yet) assertThat(runNative()).isNotEmpty(); runOrmBacked(); @@ -118,6 +130,9 @@ class DtoQueryPlanCaptureTest extends BaseTestCase { void nativeDtoQuery_withProfileLocation_capturesQueryPlan() { ResetBasicData.reset(); + // drain stale captures first (see nativeDtoQuery_capturesQueryPlan) + drainCapturedPlans(); + // build the plan first (default threshold -> no capture yet) assertThat(runNativeWithLocation()).isNotEmpty();