Vonage / vonage-java-sdk

Vonage Server SDK for Java. API support for SMS, Messages, Voice, Text-to-Speech, Numbers, Verify (2FA), Video and more.
https://developer.vonage.com/en/home
Apache License 2.0
96 stars 121 forks source link

Error from no-content responses #301

Closed slorello89 closed 3 years ago

slorello89 commented 4 years ago

https://github.com/Vonage/vonage-java-sdk/blob/0a58c70440c34c67e36d5606235d967e07f7d5ec/src/main/java/com/nexmo/client/logging/LoggingUtils.java#L33

Looks like the logger tosses an exception if you run into a situation where there is a null entity (e.g. NoContent responses)

Looks like it should probably validate the response code isn't a 204 or do some null checking. Exception I got from running the DeleteApplication code snippet:

Exception in thread "main" java.lang.IllegalArgumentException: Entity may not be null
        at org.apache.http.util.Args.notNull(Args.java:54)
        at org.apache.http.util.EntityUtils.toString(EntityUtils.java:307)
        at com.vonage.client.logging.LoggingUtils.logResponse(LoggingUtils.java:35)
        at com.vonage.client.AbstractMethod.execute(AbstractMethod.java:105)
        at com.vonage.client.application.ApplicationEndpoint.delete(ApplicationEndpoint.java:54)
        at com.vonage.client.application.ApplicationClient.deleteApplication(ApplicationClient.java:90)
        at com.vonage.quickstart.application.DeleteApplication.main(DeleteApplication.java:41)
yallen011 commented 3 years ago

steps to reproduce? Did you run the DeleteApplication as is? or did you change anything to cause that error?

slorello89 commented 3 years ago

I just ran the Delete application as is - Delete Application, by design, responds with no content - guessing that getEntity returns null if there's no response body?

vyj7 commented 3 years ago

@yallen011 I would like to work on this issue.

vyj7 commented 3 years ago

@yallen011 This the PR I have raised for the fix: https://github.com/Vonage/vonage-java-sdk/pull/304

yallen011 commented 3 years ago

@vyj7 thank you for your contribution to the SDK. I will start reviewing it.