Commit a7990f3
committed
[SPARK-55755][SQL][TESTS] Handle null ArithmeticException message on JDK 25
### What changes were proposed in this pull request?
On JDK 25, `Math.multiplyExact`/`Math.addExact` may throw `ArithmeticException` without a message (null instead of `"long overflow"`). This causes `NullPointerException` in tests that check the raw exception message via `.getMessage.contains(...)`.
This PR:
1. **`MathUtils.withOverflow`**: Provides a fallback message `"Overflow"` when the raw JDK exception message is null, preventing null propagation into Spark error conditions (both interpreted and codegen paths).
2. **Test assertions**: Makes raw `ArithmeticException` message checks null-safe across:
- `DateExpressionsSuite` (line 1825)
- `CatalystTypeConvertersSuite` (line 305)
- `DateTimeUtilsSuite` (line 835)
- `IntervalUtilsSuite` (line 593)
- `TimestampFormatterSuite` (lines 451, 453)
### Why are the changes needed?
The JDK 25 scheduled CI build fails with:
```
java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "$org_scalatest_assert_macro_left" is null
at DateExpressionsSuite.scala:1825
```
See: https://github.com/apache/spark/actions/runs/22513372344/job/65226962993
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing tests pass on JDK 17. The `MathUtils.withOverflow` fix ensures non-null messages regardless of JDK version.
### Was this patch authored or co-authored using generative AI tooling?
Yes, co-authored with GitHub Copilot.
Closes #54553 from yaooqinn/fix-jdk25-long-overflow.
Authored-by: Kent Yao <kentyao@microsoft.com>
Signed-off-by: Kent Yao <kentyao@microsoft.com>1 parent 730d375 commit a7990f3
6 files changed
Lines changed: 16 additions & 8 deletions
File tree
- sql
- api/src/main/scala/org/apache/spark/sql/catalyst/util
- catalyst/src/test/scala/org/apache/spark/sql/catalyst
- expressions
- util
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
106 | | - | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1822 | 1822 | | |
1823 | 1823 | | |
1824 | 1824 | | |
1825 | | - | |
| 1825 | + | |
| 1826 | + | |
1826 | 1827 | | |
1827 | 1828 | | |
1828 | 1829 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
835 | | - | |
| 835 | + | |
| 836 | + | |
836 | 837 | | |
837 | 838 | | |
838 | 839 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
| 594 | + | |
594 | 595 | | |
595 | 596 | | |
596 | 597 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | | - | |
| 451 | + | |
| 452 | + | |
452 | 453 | | |
453 | | - | |
| 454 | + | |
454 | 455 | | |
455 | 456 | | |
456 | 457 | | |
| |||
0 commit comments