Skip to content

Commit f5549d7

Browse files
committed
[SPARK-50984][SQL][TESTS] Make ExpressionImplUtilsSuite robust by matching JDK msgs via regex
### What changes were proposed in this pull request? This PR aims to make `ExpressionImplUtilsSuite` robust and simpler by matching JDK msgs via regex. ### Why are the changes needed? Historically, the error messages are different across JDK versions. https://github.com/apache/spark/blob/44966c94b686df72b827307d3c3eadc6804abaf2/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtilsSuite.scala#L290-L295 In JDK 17.0.14, the error messages are different in some distributions. Note that it succeeds with GitHub Action Zulu distribution. ``` [info] - AesEncrypt Expected Errors *** FAILED *** (8 milliseconds) ... [info] Analysis: [info] JavaCollectionWrappers$JMapWrapper("detailMessage": "Input length not multiple of 16 bytes" -> "Input length must be multiple of 16 when decrypting with padded cipher") ``` We had better make it more robust. ### Does this PR introduce _any_ user-facing change? No. This is a test-only change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #49661 from dongjoon-hyun/SPARK-50984. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 44966c9 commit f5549d7

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package org.apache.spark.sql.catalyst.expressions
1919

20-
import org.apache.commons.lang3.{JavaVersion, SystemUtils}
21-
2220
import org.apache.spark.{SparkFunSuite, SparkIllegalArgumentException, SparkRuntimeException}
2321
import org.apache.spark.unsafe.types.UTF8String
2422

@@ -287,12 +285,6 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
287285
}
288286
}
289287

290-
// JDK-8267125 changes tag error message at Java 18
291-
val msgTagMismatch = if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_17)) {
292-
"Tag mismatch!"
293-
} else {
294-
"Tag mismatch"
295-
}
296288
val corruptedCiphertexts = Seq(
297289
// This is truncated
298290
TestCase(
@@ -304,8 +296,7 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
304296
errorParamsMap = Map(
305297
"parameter" -> "`expr`, `key`",
306298
"functionName" -> "`aes_encrypt`/`aes_decrypt`",
307-
"detailMessage" ->
308-
"Input length must be multiple of 16 when decrypting with padded cipher"
299+
"detailMessage" -> "Input length .*"
309300
)
310301
),
311302
// The ciphertext is corrupted
@@ -318,7 +309,7 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
318309
errorParamsMap = Map(
319310
"parameter" -> "`expr`, `key`",
320311
"functionName" -> "`aes_encrypt`/`aes_decrypt`",
321-
"detailMessage" -> msgTagMismatch
312+
"detailMessage" -> "Tag mismatch[!]?"
322313
)
323314
),
324315
// Valid ciphertext, wrong AAD
@@ -332,7 +323,7 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
332323
errorParamsMap = Map(
333324
"parameter" -> "`expr`, `key`",
334325
"functionName" -> "`aes_encrypt`/`aes_decrypt`",
335-
"detailMessage" -> msgTagMismatch
326+
"detailMessage" -> "Tag mismatch[!]?"
336327
)
337328
)
338329
)
@@ -350,7 +341,8 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
350341
f(t)
351342
},
352343
condition = t.expectedErrorClassOpt.get,
353-
parameters = t.errorParamsMap
344+
parameters = t.errorParamsMap,
345+
matchPVals = true
354346
)
355347
}
356348

0 commit comments

Comments
 (0)