Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/11487#discussion_r55160833
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/ScalaReflectionSuite.scala
---
@@ -237,4 +241,45 @@ class ScalaReflectionSuite extends SparkFunSuite {
assert(anyTypes.forall(!_.isPrimitive))
assert(anyTypes === Seq(classOf[java.lang.Object],
classOf[java.lang.Object]))
}
+
+ private def testThreadSafetyFor(name: String)(exec: () => Any) = {
+ test(s"thread safety of ${name}") {
+ for (_ <- 0 until 100) {
--- End diff --
@srowen Thank you for your comment.
> `(0 until 100).foreach`?
I repeated the test 100 times here because it is for thread-safety. Thread
safety problem sometimes happens but sometimes doesn't.
> You can import `java.net.URLClassLoader`.
I'll modify to use import.
> It doesn't really seem like you need a method here; it took a moment to
see there was a test in here.
I'll modify to move out of the method.
> Maybe it's obvious to you but why do all these classes/methods need to be
tested separately?
The methods are public, i.e. can be called by multi-thread, so I thought
these also need to be tested.
But I'm wondering some of them could be removed?
> And is this locking still safe in 2.11?
Yes, reflection in Scala 2.11 is thread-safe.
If we don't support Scala 2.10, these lockings in `ScalaReflection` would
not be needed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]