Skip to content

fix(bqjdbc): fix BigDecimal usage in mocks#13207

Merged
Neenu1995 merged 1 commit into
mainfrom
ns/bigdecimal-test-fix
May 15, 2026
Merged

fix(bqjdbc): fix BigDecimal usage in mocks#13207
Neenu1995 merged 1 commit into
mainfrom
ns/bigdecimal-test-fix

Conversation

@Neenu1995
Copy link
Copy Markdown
Contributor

@Neenu1995 Neenu1995 commented May 15, 2026

ci / split-units (java-bigquery, 25) check in all JDBC PRs suddenly started failing.

Root Cause Analysis

1. JDK 25 Class Layout Restructuring

OpenJDK 25 restructured the internal layouts and private fields of core classes—including java.math.BigDecimal and java.math.BigInteger—to lay the groundwork for Project Valhalla's value types and flat objects.

2. Bytecode Compatibility Break

Mockito’s final-class mocking relies on the ByteBuddy agent (v1.12.19 in this module) to instrument core JDK classes at runtime. Under JDK 25, the restructured bytecode layouts collided with ByteBuddy's instrumentation patterns. This corrupted internal math helper methods (such as needIncrement() and divideAndRound()), causing subsequent standard BigDecimal operations across the JVM lifecycle to compute incorrect values and trigger the Rounding necessary exception.

3. Strict Module Encapsulation

JDK 25 strictly enforces strong encapsulation of the java.base module. Dynamic runtime bytecode manipulation of core JDK classes is increasingly unstable without explicit compatibility updates to agents.

Resolution

By replacing mock(BigDecimal.class) with a concrete new BigDecimal("123.456") instance in BigQueryCallableStatementTest.java, we completely bypass runtime bytecode manipulation, ensuring cross-version compatibility from JDK 11 through JDK 25+.

@Neenu1995 Neenu1995 requested review from a team as code owners May 15, 2026 17:41
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces mocked BigDecimal instances with concrete BigDecimal values in several test cases within BigQueryCallableStatementTest.java, specifically in methods testing parameter retrieval and setting by index and name. I have no feedback to provide.

@Neenu1995 Neenu1995 merged commit 65674c2 into main May 15, 2026
165 checks passed
@Neenu1995 Neenu1995 deleted the ns/bigdecimal-test-fix branch May 15, 2026 18:06
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.

2 participants