dongjoon-hyun commented on code in PR #57130:
URL: https://github.com/apache/spark/pull/57130#discussion_r3546216537


##########
sql/connect/common/src/main/scala/org/apache/spark/sql/connect/common/DataTypeProtoConverter.scala:
##########
@@ -151,10 +151,17 @@ object DataTypeProtoConverter {
     }
 
     if (t.hasJvmClass) {
-      SparkClassUtils
-        .classForName[UserDefinedType[_]](t.getJvmClass)
-        .getConstructor()
-        .newInstance()
+      // Verify the class is a UserDefinedType before constructing it. 
newInstance() runs the
+      // class's no-arg constructor, so load it without initializing and check 
the type first,
+      // rather than instantiating an arbitrary client-provided class name and 
relying on a
+      // later cast (which happens only after the constructor has already run).
+      val clazz = 
SparkClassUtils.classForName[UserDefinedType[_]](t.getJvmClass, initialize = 
false)

Review Comment:
   Could you double-check the line length?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to