Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Cannot un-marshal case classes when encountering an empty Map #11

Closed
collinvandyck opened this issue May 19, 2011 · 3 comments
Closed

Comments

@collinvandyck
Copy link

import com.codahale.simplespec.Spec
import com.codahale.jerkson.Json
import java.io.{StringWriter, StringReader}

case class PayloadConfiguration(networkId: Int, simulation: Boolean, thresholds: Map[String,Double])

object PayloadConfigurationSpec extends Spec {

  class `payload configuration` {

    def `should be idempotent wrt jerkson with an empty map`() {
      val configuration = PayloadConfiguration(1, true, Map[String,Double]())
      val writer = new StringWriter
      Json.generate(configuration, writer)
      val parsed = Json.parse[PayloadConfiguration](new StringReader(writer.toString))
      parsed must beEqualTo(configuration)
    }

    def `should be idempotent wrt jerkson with a non-empty map`() {
      val configuration = PayloadConfiguration(1, true, Map[String,Double]("a" -> 1.0))
      val writer = new StringWriter
      Json.generate(configuration, writer)
      val parsed = Json.parse[PayloadConfiguration](new StringReader(writer.toString))
      parsed must beEqualTo(configuration)
    }

  }

}

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/cvandyck/code/syncie/target/scala_2.8.1/test-resources:/Users/cvandyck/code/syncie/target/scala_2.8.1/resources:/System/Library/Java/Support/Deploy.bundle/Contents/Resources/Java/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/alt-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/Users/cvandyck/code/syncie/target/scala_2.8.1/test-classes:/Users/cvandyck/code/syncie/target/scala_2.8.1/classes:/Users/cvandyck/code/syncie/project/boot/scala-2.8.1/lib/scala-compiler.jar:/Users/cvandyck/code/syncie/project/boot/scala-2.8.1/lib/scala-library.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-continuation-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/hornetq-core-client-2.1.2.Final.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-server-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-servlets-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-io-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jersey-core-1.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/test/simplespec_2.8.1-0.2.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/guice-2.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/test/mockito-all-1.8.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/commons-pool-1.5.4.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jul-to-slf4j-1.6.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jerkson_2.8.1-0.1.6.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-security-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jackson-mapper-asl-1.7.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jersey-guice-1.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/netty-3.2.0.Final.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/logula_2.8.1-2.1.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/test/specs_2.8.1-1.6.6.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/paranamer-2.3.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/servlet-api-2.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/test/specs_2.8.0-1.6.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/slf4j-api-1.6.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jackson-core-asl-1.7.3.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/log4j-1.2.16.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/guice-servlet-2.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jersey-scala_2.8.1-0.1.2.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/hornetq-bootstrap-2.1.2.Final.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jersey-server-1.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/hornetq-core-2.1.2.Final.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-http-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/metrics_2.8.1-2.0.0-BETA10.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/fig_2.8.1-1.1.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/commons-cli-1.2.jar:/Users/cvandyck/code/syncie/lib/zookeeper-3.3.3.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/commons-lang-2.5.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/easy-process_2.8.1-1.0-SNAPSHOT.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-client-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-util-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/aopalliance-1.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/commons-codec-1.2.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/guice-multibindings-2.0.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/asm-3.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/embedded-hornet_2.8.1-1.0.9.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/jetty-servlet-7.3.1.v20110307.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/dropwizard_2.8.1-0.0.2.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/scala-utils_2.8.1-0.1.3-SNAPSHOT.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/slf4j-log4j12-1.6.1.jar:/Users/cvandyck/code/syncie/lib_managed/scala_2.8.1/compile/commons-io-2.0.1.jar com.yammer.syncie.job.PayloadConfigurationSpec
Specification "PayloadConfigurationSpec"
  payload configuration should
  x  be idempotent wrt jerkson with an empty map
    com.codahale.jerkson.ParsingException: Invalid JSON. (ParsingException.scala:23)
    at com.codahale.jerkson.ParsingException$.apply(ParsingException.scala:23)
    at com.codahale.jerkson.Parser$class.parse(Parser.scala:84)
    at com.codahale.jerkson.Json$.parse(Json.scala:6)
    at com.codahale.jerkson.Parser$class.parse(Parser.scala:34)
    at com.codahale.jerkson.Json$.parse(Json.scala:6)
    at com.yammer.syncie.job.PayloadConfigurationSpec$payload$u0020configuration.should$u0020be$u0020idempotent$u0020wrt$u0020jerkson$u0020with$u0020an$u0020empty$u0020map(PayloadConfigurationSpec.scala:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.codahale.simplespec.Spec$$anonfun$2$$anonfun$apply$1$$anonfun$apply$mcV$sp$4$$anonfun$apply$2.apply(Spec.scala:40)
    at org.specs.specification.LifeCycle$class.withCurrent(ExampleLifeCycle.scala:60)
    at org.specs.specification.Examples.withCurrent(Examples.scala:52)
    at org.specs.specification.Examples$$anonfun$specifyExample$1.apply(Examples.scala:111)
    at org.specs.specification.Examples$$anonfun$specifyExample$1.apply(Examples.scala:111)
    at org.specs.specification.ExampleExecution$$anonfun$3$$anonfun$apply$5.apply(ExampleLifeCycle.scala:213)
    at scala.Option.getOrElse(Option.scala:104)
    at org.specs.specification.LifeCycle$class.executeExpectations(ExampleLifeCycle.scala:84)
    at org.specs.specification.BaseSpecification.executeExpectations(BaseSpecification.scala:58)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$class.id$1(ExampleContext.scala:32)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:80)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.ExampleContext$class.executeExpectations(ExampleContext.scala:80)
    at org.specs.specification.Examples.executeExpectations(Examples.scala:52)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$class.id$1(ExampleContext.scala:32)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:80)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.ExampleContext$class.executeExpectations(ExampleContext.scala:80)
    at org.specs.specification.Examples.executeExpectations(Examples.scala:52)
    at org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle.scala:213)
    at org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle.scala:192)
    at org.specs.specification.ExampleExecution$$anonfun$2.apply(ExampleLifeCycle.scala:175)
    at org.specs.specification.ExampleExecution.execute(ExampleLifeCycle.scala:246)
    at org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.apply(SpecificationExecutor.scala:70)
    at org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.apply(SpecificationExecutor.scala:70)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.SpecificationExecutor$class.executeExample(SpecificationExecutor.scala:70)
    at org.specs.specification.BaseSpecification.executeExample(BaseSpecification.scala:58)
    at org.specs.specification.BaseSpecification.executeExample(BaseSpecification.scala:58)
    at org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(ExampleLifeCycle.scala:119)
    at org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(ExampleLifeCycle.scala:119)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.ExampleLifeCycle$class.executeExample(ExampleLifeCycle.scala:119)
    at org.specs.specification.Examples.executeExample(Examples.scala:52)
    at org.specs.specification.Examples.executeExample(Examples.scala:52)
    at org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples.scala:80)
    at org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples.scala:80)
    at scala.Option.map(Option.scala:129)
    at org.specs.specification.Examples.executeExamples(Examples.scala:80)
    at org.specs.specification.ExampleStructure$class.ownFailures(ExampleStructure.scala:58)
    at org.specs.specification.Examples.ownFailures(Examples.scala:52)
    at org.specs.specification.ExampleStructure$class.failures(ExampleStructure.scala:64)
    at org.specs.specification.Examples.failures(Examples.scala:52)
    at org.specs.specification.Examples.failures(Examples.scala:52)
    at org.specs.execute.HasResults$class.failureAndErrors(HasResults.scala:61)
    at org.specs.specification.Examples.failureAndErrors(Examples.scala:52)
    at org.specs.execute.HasResults$class.hasFailureOrErrors(HasResults.scala:59)
    at org.specs.specification.Examples.hasFailureOrErrors(Examples.scala:52)
    at org.specs.runner.OutputReporter$class.status$1(ConsoleReporter.scala:223)
    at org.specs.runner.OutputReporter$class.reportExample(ConsoleReporter.scala:232)
    at org.specs.Specification.reportExample(Specification.scala:43)
    at org.specs.runner.OutputReporter$$anonfun$reportExamples$1.apply(ConsoleReporter.scala:210)
    at org.specs.runner.OutputReporter$$anonfun$reportExamples$1.apply(ConsoleReporter.scala:209)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.specs.runner.OutputReporter$class.reportExamples(ConsoleReporter.scala:209)
    at org.specs.Specification.reportExamples(Specification.scala:43)
    at org.specs.runner.OutputReporter$class.printSus(ConsoleReporter.scala:174)
    at org.specs.Specification.printSus(Specification.scala:43)
    at org.specs.runner.OutputReporter$class.displaySus$1(ConsoleReporter.scala:141)
    at org.specs.runner.OutputReporter$$anonfun$reportSystems$1.apply(ConsoleReporter.scala:147)
    at org.specs.runner.OutputReporter$$anonfun$reportSystems$1.apply(ConsoleReporter.scala:142)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.specs.runner.OutputReporter$class.reportSystems(ConsoleReporter.scala:142)
    at org.specs.Specification.reportSystems(Specification.scala:43)
    at org.specs.runner.OutputReporter$class.reportSpec(ConsoleReporter.scala:87)
    at org.specs.Specification.reportSpec(Specification.scala:43)
    at org.specs.runner.OutputReporter$$anonfun$report$1.apply(ConsoleReporter.scala:74)
    at org.specs.runner.OutputReporter$$anonfun$report$1.apply(ConsoleReporter.scala:74)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.specs.runner.OutputReporter$class.report(ConsoleReporter.scala:74)
    at org.specs.Specification.report(Specification.scala:43)
    at org.specs.runner.OutputReporter$class.report(ConsoleReporter.scala:65)
    at org.specs.Specification.report(Specification.scala:43)
    at org.specs.Specification.report(Specification.scala:43)
    at org.specs.runner.Reporter$class.reportSpecs(Reporter.scala:195)
    at org.specs.Specification.reportSpecs(Specification.scala:43)
    at org.specs.runner.Reporter$class.main(Reporter.scala:140)
    at org.specs.Specification.main(Specification.scala:43)
    at com.yammer.syncie.job.PayloadConfigurationSpec.main(PayloadConfigurationSpec.scala)
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.Double out of END_OBJECT token
 at [Source: N/A; line: -1, column: -1]
    at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:160)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:198)
    at com.codahale.jerkson.deser.MapDeserializer.deserialize(MapDeserializer.scala:24)
    at com.codahale.jerkson.deser.MapDeserializer.deserialize(MapDeserializer.scala:11)
    at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2112)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1004)
    at com.codahale.jerkson.deser.CaseClassDeserializer$$anonfun$deserialize$1$$anonfun$apply$1.apply(CaseClassDeserializer.scala:49)
    at com.codahale.jerkson.deser.CaseClassDeserializer$$anonfun$deserialize$1$$anonfun$apply$1.apply(CaseClassDeserializer.scala:41)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:57)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:43)
    at com.codahale.jerkson.deser.CaseClassDeserializer$$anonfun$deserialize$1.apply(CaseClassDeserializer.scala:41)
    at com.codahale.jerkson.deser.CaseClassDeserializer$$anonfun$deserialize$1.apply(CaseClassDeserializer.scala:39)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:32)
    at com.codahale.jerkson.deser.CaseClassDeserializer.deserialize(CaseClassDeserializer.scala:39)
    at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2112)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1004)
    at com.codahale.jerkson.Parser$class.parse(Parser.scala:81)
    ... 106 more
  +  be idempotent wrt jerkson with a non-empty map

Total for specification "PayloadConfigurationSpec":
Finished in 0 second, 512 ms
2 examples, 1 expectation, 0 failure, 1 error

@codahale
Copy link
Owner

I think this is a regression. I'll fix it today.

@collinvandyck
Copy link
Author

Did you already fix? Anyways, upgrading to the latest dropwizard along with Jerkson fixed this. Thanks.

@codahale
Copy link
Owner

Might be why I thought it was a regression. Glad to hear it's fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants