Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException for HEAD request with HttpClient connector #825

Closed
olivierlemasle opened this issue Sep 21, 2016 · 0 comments
Closed

Comments

@olivierlemasle
Copy link
Contributor

Using the Apache HttpClient connector, a NullPointerException is thrown if the response contains no entity (which is the case for a HEAD request).

I encountered the issue with client.identity().roles().checkProjectUserRole() which is maped to a HEAD request (http://developer.openstack.org/api-ref/identity/v3/index.html?expanded=check-whether-user-has-role-assignment-on-project-detail,check-whether-group-has-role-assignment-on-project-detail#check-whether-group-has-role-assignment-on-project).

Then, when the HTTP response is mapped to an ActionResponse in https://github.com/ContainX/openstack4j/blob/3.0.2/core/src/main/java/org/openstack4j/core/transport/functions/ResponseToActionResponse.java#L31, the entity is null in https://github.com/ContainX/openstack4j/blob/3.0.2/connectors/httpclient/src/main/java/org/openstack4j/connectors/httpclient/HttpResponseImpl.java#L127, which causes the NullPointerException.

java.lang.NullPointerException
    at org.openstack4j.connectors.httpclient.HttpResponseImpl.readEntity(HttpResponseImpl.java:127) [openstack4j-httpclient-3.0.2.jar:?]
    at org.openstack4j.core.transport.functions.ResponseToActionResponse.apply(ResponseToActionResponse.java:31) [openstack4j-core-3.0.2.jar:?]
    at org.openstack4j.core.transport.functions.ResponseToActionResponse.apply(ResponseToActionResponse.java:22) [openstack4j-core-3.0.2.jar:?]
    at org.openstack4j.core.transport.HttpEntityHandler.handle(HttpEntityHandler.java:36) [openstack4j-core-3.0.2.jar:?]
    at org.openstack4j.connectors.httpclient.HttpResponseImpl.getEntity(HttpResponseImpl.java:65) [openstack4j-httpclient-3.0.2.jar:?]
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:193) [openstack4j-core-3.0.2.jar:?]
    at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:187) [openstack4j-core-3.0.2.jar:?]
    at org.openstack4j.openstack.identity.v3.internal.RoleServiceImpl.checkProjectUserRole(RoleServiceImpl.java:53) [openstack4j-core-3.0.2.jar:?]
olivierlemasle added a commit to olivierlemasle/openstack4j that referenced this issue Sep 21, 2016
olivierlemasle added a commit to olivierlemasle/openstack4j that referenced this issue Sep 21, 2016
@auhlig auhlig closed this as completed in 0a09e59 Sep 27, 2016
auhlig added a commit that referenced this issue Sep 27, 2016
Fix #825 - NullPointerException in HttpClient connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant