Permalink
Browse files

Merge branch 'rpcCrash' of github.com:siroky/Payola into rpcCrash

  • Loading branch information...
2 parents aa5ed97 + 4934b53 commit b1e1b8e36653ebf2da88fe6188db3b6bcb2124bc @jirihelmich jirihelmich committed Apr 10, 2012
View
@@ -5,6 +5,7 @@ tmp/
payola/lib/s2js-adapters_2.9.1-0.2.jar
payola/lib/s2js-compiler_2.9.1-0.2.jar
payola/web/server/public/javascripts/compiled/
+payola/web/server/public/javascripts/runtime/
payola/web/server/public/javascripts/runtime-shared/
payola/web/server/public/javascripts/runtime-client/
payola/web/server/public/javascripts/common/
@@ -181,7 +181,7 @@ class JSONSerializer
&& !obj.isInstanceOf[Array[_]]) {
// Must be AnyRef, otherwise it wouldn't get into the processedObjects array
result = serializePlainObject(obj.asInstanceOf[AnyRef], serializeObjectAsReference, objectID, processedObjects)
- } else if (serializationClass.isDefined) {
+ } else if (serializationClass.isDefined && !serializationClass.get._2.isInstanceOf[CustomValueSerializationRule[_]]) {
val rule = serializationClass.get._2
result = rule match {
case basic: BasicSerializationRule => serializeWithRule(obj.asInstanceOf[AnyRef], basic, objectID, processedObjects)
@@ -38,6 +38,9 @@ class Group(val name: String)
val thisIsNotInTrait = null
}
+class Exception1(val message: String = "", val cause: Exception = null) extends RuntimeException
+class Exception2(override val message: String = "", cause: Exception = null) extends Exception1(message, cause)
+
class Scala2JSONTest extends FlatSpec with ShouldMatchers {
"JSONSerializer" should "handle cyclic dependencies and a BasicSerializationRule." in {
val u: User = new User("Franta")
@@ -70,4 +73,14 @@ class Scala2JSONTest extends FlatSpec with ShouldMatchers {
JSONUtilities.escapeString("\"jame\"go\"\"to hess\"\"") should equal ("\"\\\"jame\\\"go\\\"\\\"to hess\\\"\\\"\"")
}
+ "exception" should "have a message field serialized" in {
+ val serializer: JSONSerializer = new JSONSerializer()
+ val exc = new Exception2("Hello")
+
+ val rule = new CustomValueSerializationRule[Exception2]("message", { (_, exc) => exc.message })
+ serializer.addSerializationRule(new SimpleSerializationClass(classOf[Exception2]), rule)
+
+ assume(serializer.serialize(exc).contains("Hello"))
+ }
+
}

0 comments on commit b1e1b8e

Please sign in to comment.