Skip to content

Commit 3f54ac5

Browse files
committed
Revert "[SPARK-55755][SQL][TESTS] Handle null ArithmeticException message on JDK 25"
This reverts commit a7990f3.
1 parent a7990f3 commit 3f54ac5

6 files changed

Lines changed: 8 additions & 16 deletions

File tree

sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/MathUtils.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ object MathUtils {
9494
f
9595
} catch {
9696
case e: ArithmeticException =>
97-
// On JDK 25+, Math.*Exact may throw ArithmeticException without a message
98-
val message = if (e.getMessage != null) e.getMessage else "Overflow"
99-
throw ExecutionErrors.arithmeticOverflowError(message, hint, context)
97+
throw ExecutionErrors.arithmeticOverflowError(e.getMessage, hint, context)
10098
}
10199
}
102100

@@ -105,8 +103,7 @@ object MathUtils {
105103
|try {
106104
| $evalCode
107105
|} catch (ArithmeticException e) {
108-
| String msg = e.getMessage() != null ? e.getMessage() : "Overflow";
109-
| throw QueryExecutionErrors.arithmeticOverflowError(msg, "", $context);
106+
| throw QueryExecutionErrors.arithmeticOverflowError(e.getMessage(), "", $context);
110107
|}
111108
|""".stripMargin
112109
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystTypeConvertersSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ class CatalystTypeConvertersSuite extends SparkFunSuite with SQLHelper {
302302
val errMsg = intercept[ArithmeticException] {
303303
IntervalUtils.durationToMicros(Duration.ofSeconds(Long.MaxValue, Long.MaxValue))
304304
}.getMessage
305-
// On JDK 25+, Math.multiplyExact may throw ArithmeticException without a message
306-
assert(errMsg == null || errMsg.contains("long overflow"))
305+
assert(errMsg.contains("long overflow"))
307306
}
308307

309308
test("SPARK-35726: Truncate java.time.Duration by fields of day-time interval type") {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,7 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
18221822
null)
18231823
}.getCause
18241824
assert(e.isInstanceOf[ArithmeticException])
1825-
// On JDK 25+, Math.multiplyExact may throw ArithmeticException without a message
1826-
assert(e.getMessage == null || e.getMessage.contains("long overflow"))
1825+
assert(e.getMessage.contains("long overflow"))
18271826

18281827
checkEvaluation(
18291828
TimestampAddInterval(

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ class DateTimeUtilsSuite extends SparkFunSuite with Matchers with SQLHelper {
832832
val msg = intercept[ArithmeticException] {
833833
DateTimeUtils.localDateTimeToMicros(dt)
834834
}.getMessage
835-
// On JDK 25+, Math.multiplyExact may throw ArithmeticException without a message
836-
assert(msg == null || msg == "long overflow")
835+
assert(msg == "long overflow")
837836
}
838837
}
839838

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/IntervalUtilsSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,7 @@ class IntervalUtilsSuite extends SparkFunSuite with SQLHelper {
590590
val errMsg = intercept[ArithmeticException] {
591591
durationToMicros(Duration.ofDays(106751991 + 1))
592592
}.getMessage
593-
// On JDK 25+, Math.multiplyExact may throw ArithmeticException without a message
594-
assert(errMsg == null || errMsg.contains("long overflow"))
593+
assert(errMsg.contains("long overflow"))
595594
}
596595

597596
test("SPARK-34615: period to months") {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/TimestampFormatterSuite.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,9 @@ class TimestampFormatterSuite extends DatetimeFormatterSuite {
448448
assert(formatter.parse("294247") === date(294247))
449449
assert(formatter.parse("-290307") === date(-290307))
450450
val e1 = intercept[ArithmeticException](formatter.parse("294248"))
451-
// On JDK 25+, Math.multiplyExact may throw ArithmeticException without a message
452-
assert(e1.getMessage == null || e1.getMessage === "long overflow")
451+
assert(e1.getMessage === "long overflow")
453452
val e2 = intercept[ArithmeticException](formatter.parse("-290308"))
454-
assert(e2.getMessage == null || e2.getMessage === "long overflow")
453+
assert(e2.getMessage === "long overflow")
455454
}
456455

457456
test("SPARK-36418: default parsing w/o pattern") {

0 commit comments

Comments
 (0)