kairosdb / kairosdb-client

Java Client for KairosDB
65 stars 67 forks source link

NullPointerException in AbstractClient #34

Closed dimas closed 9 years ago

dimas commented 9 years ago
    at org.kairosdb.client.AbstractClient.getResponse(AbstractClient.java:177)
    at org.kairosdb.client.AbstractClient.pushMetrics(AbstractClient.java:132)

I guess the server is either returning malformed JSON or just does not include "errors" there. Cannot tell because the actual response is not logged. Also have no idea how to reproduce as it happens from time to time only.

FrEaKmAn commented 9 years ago

Can you check kairosdb or cassandra log for possible errors?

jsabin commented 9 years ago

Can you give more information about this problem?

dimas commented 9 years ago

No, I am sorry guys. That thing runs in a live system under a lot of requests and the issue is not something that happens every second. It is kind of difficult to collect evidences when a problem occurs because all Kairos servers are behind a load balancer so you do not know to which sevrer this particular request went and in the end you have to dig through a combined log which is huge. If I could reproduce it with a single KairosDB + single Cassandra setup I would be happy to collect all the evidences.

My point is that that kind of things like unexpected reponse from a server happens in real life so the code should be prepared for it and handle it accordingly. For example by returning a null result instead of trying to dereference null. Or better - by throwing an appropriate exception that says the resonse is malformed or status code is not something it expected. And possibly by logging some evidences - like the entire response body (but with debug level of course), status code, etc.

Cheers

jsabin commented 9 years ago

I'm looking for a full stack trace so I can identify where the problem is.

jsabin commented 9 years ago

I can't reproduce so I'm closing this issue.

dimas commented 9 years ago

Guys, just to let you know, the Gson you are using returns null for an empty string - https://github.com/google/gson/issues/457

So the NPE will happen whenever server returns an empty body. Sure thing it is a problem on the server side then but a good client is better be prepared for shitty response.