HalBuilder / halbuilder-json

HalBuilder JSON Support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please push the latest code to maven

drsnyder opened this issue · comments

Hi Mark, do you mind pushing the latest code to maven? I'm having an issue with NPEs deserializing maps that have null values. I think this commit will probably resolve the issue since the root of the problem is in ImmutableMap.

Thanks!
Damon

Unfortunately that commit won't help as that's after I started switching to using Javaslang in core, which has now moved to being a backwards incompatible API ( of which a newer implementation of JsonRepresentationReader/Writer exist). I do need to make a support release soon that I've been to do to resolve an issue for Android usage.

Do you have an example hal+json document I can use to add a test-case?

Can you post the NPE stacktrace?

Here is the HAL document that is causing the issue. It came from this API.

Here is the NPE stacktrace:

! java.lang.NullPointerException: null value in entry: avatarUrl=null
! at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33) ~[guava-18.0.jar:na]
! at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:88) ~[guava-18.0.jar:na]
! at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:294) ~[guava-18.0.jar:na]
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.readProperties(JsonRepresentationReader.java:136) ~[halbuilder-json-4.0.3.jar:na]
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.readResource(JsonRepresentationReader.java:61) ~[halbuilder-json-4.0.3.jar:na]
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.readResources(JsonRepresentationReader.java:152) ~[halbuilder-json-4.0.3.jar:na]
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.readResource(JsonRepresentationReader.java:62) ~[halbuilder-json-4.0.3.jar:na]
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.read(JsonRepresentationReader.java:48) ~[halbuilder-json-4.0.3.jar:na]
! Causing: com.theoryinpractise.halbuilder.api.RepresentationException: java.lang.NullPointerException: null value in entry: avatarUrl=null
! at com.theoryinpractise.halbuilder.json.JsonRepresentationReader.read(JsonRepresentationReader.java:50) ~[halbuilder-json-4.0.3.jar:na]
! at com.wikia.workers.contententityworker.gateway.DiscussionsGateway.getTrendingThreadMap(DiscussionsGateway.java:138) [main/:na]
! at com.wikia.workers.contententityworker.gateway.DiscussionsGateway.getTrendingThreads(DiscussionsGateway.java:81) [main/:na]
! at com.wikia.workers.contententityworker.gateway.DiscussionsGatewayIntegrationTest.testGetTrendingThreads(DiscussionsGatewayIntegrationTest.java:85) [test/:na]
! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_73]
! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_73]
! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_73]
! at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_73]
! at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) [junit-4.11.jar:na]
! at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na]
! at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) [junit-4.11.jar:na]
! at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.11.jar:na]
! at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) [junit-4.11.jar:na]
! at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) [junit-4.11.jar:na]
! at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:na]
! at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) [junit-4.11.jar:na]
! at org.junit.rules.RunRules.evaluate(RunRules.java:20) [junit-4.11.jar:na]
! at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na]
! at org.junit.runner.JUnitCore.run(JUnitCore.java:160) [junit-4.11.jar:na]
! at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) [junit-rt.jar:na]
! at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) [junit-rt.jar:na]
! at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) [junit-rt.jar:na]
! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_73]
! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_73]
! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_73]
! at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_73]
! at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]

Thanks for the quick response.