[SPARK-35244][SQL][FOLLOWUP] Add null check for the exception cause

### What changes were proposed in this pull request?

Make sure we re-throw an exception that is not null.

### Why are the changes needed?

to be super safe

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

N/A

Closes #32387 from cloud-fan/minor.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
This commit is contained in:
Wenchen Fan 2021-04-29 09:21:32 +09:00 committed by Takeshi Yamamuro
parent 86d3bb5f7d
commit 403e4795e9

View file

@ -134,7 +134,8 @@ trait InvokeLike extends Expression with NonSQLExpression {
method.invoke(obj, args: _*)
} catch {
// Re-throw the original exception.
case e: java.lang.reflect.InvocationTargetException => throw e.getCause
case e: java.lang.reflect.InvocationTargetException if e.getCause != null =>
throw e.getCause
}
val boxedClass = ScalaReflection.typeBoxedJavaMapping.get(dataType)
if (boxedClass.isDefined) {