killbill / killbill-client-java

Java client library for Kill Bill
https://killbill.io
Apache License 2.0
33 stars 63 forks source link

unmarshalResponse masks errors that aren't in JSON format #65

Open chris13524 opened 6 years ago

chris13524 commented 6 years ago

Particularly this error.

I am getting an error when using pluginPOST:

org.killbill.billing.client.KillBillClientException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Invalid': was expecting 'null', 'true', 'false' or NaN
at [Source: org.jboss.netty.buffer.ChannelBufferInputStream@15590dd4; line: 1, column: 9]
at org.killbill.billing.client.KillBillHttpClient.unmarshalResponse(KillBillHttpClient.java:718)
at org.killbill.billing.client.KillBillHttpClient.deserializeResponse(KillBillHttpClient.java:648)
at org.killbill.billing.client.KillBillHttpClient.throwExceptionOnResponseError(KillBillHttpClient.java:632)
at org.killbill.billing.client.KillBillHttpClient.doPrepareRequest(KillBillHttpClient.java:503)
at org.killbill.billing.client.KillBillHttpClient.doPost(KillBillHttpClient.java:247)
at org.killbill.billing.client.KillBillHttpClient.doPost(KillBillHttpClient.java:242)
at org.killbill.billing.client.KillBillHttpClient.doPost(KillBillHttpClient.java:238)
at org.killbill.billing.client.KillBillClient.pluginPOST(KillBillClient.java:3979)

This is masking the actual error that is being returned. There should be a catch handler there somewhere to detect JsonParseExceptions and return response.getResponseBody() instead. Possibly, just add JsonParseException to the catch block on line 731 of KillBillHttpClient? I realize I could switch the DEBUG flag on, but if this is an intermittent error in production, that flag doesn't help too much.

chris13524 commented 6 years ago

And actually, the default Kill Bill installation logs at INFO and up and wouldn't include the debugging output even if DEBUG=true. (I think.)