Improve test coverage for batch operations plus a NPE fix for empty JDBC batch operations#19037
Merged
trask merged 2 commits intoJun 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds broader batch operation test coverage across JDBC, R2DBC, Vert.x SQL, and Lettuce instrumentation modules, while preserving current shared DB batch semantics. It also includes a narrow JDBC javaagent fix for a potential NPE when executeBatch() is called with an empty batch (no addBatch() calls).
Changes:
- Refactored batch tests across JDBC, R2DBC, and Vert.x SQL into parameterized tests using
BatchScenariobuilder classes, covering empty, single-statement, multi-statement-same-operation, and multi-statement-different-operation batch cases under both old and stable database semconv. - Fixed a JDBC javaagent NPE in
JdbcAdviceScope.createBatchRequest()whenexecuteBatch()is called with no prioraddBatch()calls — now creates aDbRequestwith an empty query text list andbatchSize = 0Linstead of passingnullquery text. - Added Lettuce deferred-flush (pipeline) batch tests and changed
testCancelCommandBeforeItFinishesto usehasSpansSatisfyingExactlyInAnyOrderto handle non-deterministic span ordering.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcAdviceScope.java |
NPE fix: empty executeBatch() now creates a valid DbRequest with emptyList() and batchSize=0L |
instrumentation/jdbc/testing/src/main/java/.../AbstractJdbcInstrumentationTest.java |
Replaces testBatch/testMultiBatch/testSingleItemBatch with parameterized testStatementBatch using BatchScenario |
instrumentation/r2dbc-1.0/testing/src/main/java/.../AbstractR2dbcStatementTest.java |
Replaces testBatchQueries with parameterized batchQueries covering 4 batch scenarios under both semconv modes |
instrumentation/r2dbc-1.0/library/src/test/java/.../DbExecutionTest.java |
Adds ExecutionType.BATCH to mock setup and adds dbExecutionWithEmptyBatch unit test |
instrumentation/r2dbc-1.0/library/src/test/java/.../R2dbcSqlAttributesGetterTest.java |
Adds ExecutionType.BATCH to batch mock setup |
instrumentation/vertx/.../v4_0/VertxSqlClientTest.java |
Parameterized testBatch with BatchScenario covering empty, single, and multi-statement batches |
instrumentation/vertx/.../v5_0/VertxSqlClientTest.java |
Same parameterized testBatch pattern for Vert.x 5.0 (different error type for empty batch) |
instrumentation/lettuce/.../v4_0/LettuceAsyncClientTest.java |
Adds deferred-flush batch tests; changes cancel test to InAnyOrder assertions |
instrumentation/lettuce/.../v5_0/LettuceAsyncClientTest.java |
Same deferred-flush batch tests and cancel test ordering fix for Lettuce 5.0 |
b2f5828 to
60f4444
Compare
60f4444 to
dff0496
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
laurit
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Broaden current-behavior batch operation coverage for JDBC, R2DBC, and Vert.x SQL while preserving the DB batch semantics currently on
main. The tests pin empty-batch span naming, single-operation batch behavior, and existing stable-semconv batch-size expectations before the core DB batch semantic changes land (open-telemetry/semantic-conventions#3811); the PR also includes the JDBC javaagent emptyexecuteBatch()NPE fix needed for that coverage.