JsonMappingException causes NullPointerException
See original GitHub issueMapping errors that result in a JsonMappingException
produce NullPointerException
. This is caused by the fact that the client tries to get the error stream from the connection if an IOException is thrown. But JsonMappingException
also extends IOException
. This means the client will try to get the error stream on JsonMappingException
and this causes the NPE because the stream is null:
Caused by: java.lang.NullPointerException: null
at com.googlecode.jsonrpc4j.NoCloseInputStream.markSupported(NoCloseInputStream.java:85) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.ReadContext.assertReadable(ReadContext.java:29) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcClient.readResponseNode(JsonRpcClient.java:287) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcClient.getValidResponse(JsonRpcClient.java:223) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcClient.readResponse(JsonRpcClient.java:173) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcClient.readResponse(JsonRpcClient.java:500) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:114) ~[jsonrpc4j-1.4.3.jar:1.4.3]
at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:92) ~[jsonrpc4j-1.4.3.jar:1.4.3]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
JsonMappingException (was java.lang.NullPointerException)
My theory is that Jackson JSON tries to access it as a primitive datatype, causing the crash. Still not sure what to do...
Read more >Free plan is causing JsonMappingException and ...
Hello. We are trying to implement KillBill features in our Click2CallMe app, and so far I have managed to generate catalog XML file...
Read more >Jackson Exceptions - Problems and Solutions - Baeldung
In this tutorial, we'll go over the most common Jackson Exceptions — JsonMappingException and UnrecognizedPropertyException.
Read more >Error when faceting with "missing":true - Datastax Community
Thread.run(Thread.java:748); Caused by: com.fasterxml.jackson.databind.JsonMappingException: [no message for java.lang.NullPointerException] ...
Read more >NullPointerException in InvestigationWrapper : TW-78756
JsonMappingException : (was java.lang.NullPointerException) ... ProblemOccurrencesTree$Leaf["problemOccurrences"]), caused by: java.lang.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep. Same problem. If the method returns an plain string - it’s OK. But if the method returns an object - the library throws
NullPointerException
. For example:The stack trace is identical to the listed above. It seems that somewhere missed checking to
null
.I have got a similar problem. When I send an invalid arguments to a method or do anything else that causes JsonMappingException to be thrown then I will get a NullPointerException on client. The reason is that JsonBasicServer handles all exceptions in invoke method (line 375) to a JSON error but these Jackson exceptions do not have a public constructor. But even if they had one this is invalid behavior.
The fix should be done by rethrowing of IOException that will cause that a proper JsonError.PARSE_ERROR error will be created as response in the handleRequest method.