Switching to not initializing loaded classes up front and cleaning up the test case.
This commit is contained in:
parent
5ebbd0689e
commit
a789e1a19d
2 changed files with 4 additions and 11 deletions
|
|
@ -182,21 +182,15 @@ class SerializeSpec extends AkkaSpec(SerializeSpec.config) {
|
||||||
|
|
||||||
"use ByteArraySerializer for byte arrays" in {
|
"use ByteArraySerializer for byte arrays" in {
|
||||||
val byteSerializer = ser.serializerFor(classOf[Array[Byte]])
|
val byteSerializer = ser.serializerFor(classOf[Array[Byte]])
|
||||||
byteSerializer.getClass must be(classOf[ByteArraySerializer])
|
byteSerializer.getClass must be theSameInstanceAs classOf[ByteArraySerializer]
|
||||||
|
|
||||||
val ba = "foo".getBytes("UTF-8")
|
for (a ← Seq("foo".getBytes("UTF-8"), null: Array[Byte], Array[Byte]()))
|
||||||
|
byteSerializer.fromBinary(byteSerializer.toBinary(a)) must be theSameInstanceAs a
|
||||||
(byteSerializer.toBinary(ba) eq ba) must be === true
|
|
||||||
(byteSerializer.fromBinary(ba) eq ba) must be === true
|
|
||||||
|
|
||||||
intercept[IllegalArgumentException] {
|
intercept[IllegalArgumentException] {
|
||||||
byteSerializer.toBinary("pigdog")
|
byteSerializer.toBinary("pigdog")
|
||||||
}.getMessage must be === "ByteArraySerializer only serializes byte arrays, not [pigdog]"
|
}.getMessage must be === "ByteArraySerializer only serializes byte arrays, not [pigdog]"
|
||||||
|
|
||||||
byteSerializer.toBinary(null) must be === null
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAcces
|
||||||
|
|
||||||
override def getClassFor[T: ClassTag](fqcn: String): Try[Class[_ <: T]] =
|
override def getClassFor[T: ClassTag](fqcn: String): Try[Class[_ <: T]] =
|
||||||
Try[Class[_ <: T]]({
|
Try[Class[_ <: T]]({
|
||||||
val c = Class.forName(fqcn, true, classLoader).asInstanceOf[Class[_ <: T]]
|
val c = Class.forName(fqcn, false, classLoader).asInstanceOf[Class[_ <: T]]
|
||||||
val t = implicitly[ClassTag[T]].runtimeClass
|
val t = implicitly[ClassTag[T]].runtimeClass
|
||||||
if (t.isAssignableFrom(c)) c else throw new ClassCastException(t + " is not assignable from " + c)
|
if (t.isAssignableFrom(c)) c else throw new ClassCastException(t + " is not assignable from " + c)
|
||||||
})
|
})
|
||||||
|
|
@ -101,5 +101,4 @@ class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAcces
|
||||||
} recover { case i: InvocationTargetException if i.getTargetException ne null ⇒ throw i.getTargetException }
|
} recover { case i: InvocationTargetException if i.getTargetException ne null ⇒ throw i.getTargetException }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue