[ 
https://issues.apache.org/jira/browse/HBASE-22846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16916708#comment-16916708
 ] 

Wellington Chevreuil commented on HBASE-22846:
----------------------------------------------

Actually, if not set, http requests are coming with no "content-type" header 
param at all. Here's an example from curl command _curl -vi -X POST 
"http://localhost:20550/namespaces/datasparktest22"_:
{noformat}
2019-08-27 13:04:10,424 DEBUG [qtp293508253-41] server.HttpChannel: REQUEST for 
//localhost:20550/namespaces/datasparktest22 on 
HttpChannelOverHttp@7837ac6a{r=1,c=false,a=IDLE,uri=//localhost:20550/namespaces/datasparktest22}
POST //localhost:20550/namespaces/datasparktest22 HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost:20550
Accept: */* {noformat}
Another example using _postman_ http client:
{noformat}
2019-08-27 13:07:22,191 DEBUG [qtp293508253-44] server.HttpChannel: REQUEST for 
//192.168.56.105:20550/namespaces/datasparktest182 on 
HttpChannelOverHttp@1e9640f3{r=1,c=false,a=IDLE,uri=//192.168.56.105:20550/namespaces/datasparktest182}
POST //192.168.56.105:20550/namespaces/datasparktest182 HTTP/1.1
User-Agent: PostmanRuntime/7.15.2
Accept: */*
Cache-Control: no-cache
Postman-Token: c825af07-60fb-4135-9429-60bb52d410f9
Host: 192.168.56.105:20550
Accept-Encoding: gzip, deflate
Content-Length: 0
Connection: keep-alive {noformat}
Both result in the NPE observed here. If we set any "content-type", then jersey 
directs to the proper "noBody" method, in the case of no payload specified. If 
we agree that even when no "content-type" is specified, HBase REST should still 
fulfil the request, then current PR changes should be ok. I can add extra 
testing logic for such cases. Otherwise, we would need to define extra 
validations, in order to return a 400 code, since this would be a client 
invalid request.

> Internal Error 500 when Using HBASE REST API to Create Namespace.
> -----------------------------------------------------------------
>
>                 Key: HBASE-22846
>                 URL: https://issues.apache.org/jira/browse/HBASE-22846
>             Project: HBase
>          Issue Type: Improvement
>          Components: hbase-connectors
>    Affects Versions: 2.1.1
>            Reporter: Sailesh Patel
>            Assignee: Wellington Chevreuil
>            Priority: Major
>
> When trying to the following URL to create namespace:
> Secured cluster: curl --negotiate -u : -i -k -vi -X POST 
> "http://HBASE_REST_API_HOST:20550/namespaces/datasparktest";
>  UnSecured cluster: curl -vi -X POST 
> "http://HBASE_REST_API_HOST:20550/namespaces/datasparktest";
> The following is returned on the console:
>  HTTP/1.1 500 Request failed.
> The Error in Hbase REST Server log is:
> 2019-08-13 15:44:55,080 WARN org.eclipse.jetty.servlet.ServletHandler: 
> javax.servlet.ServletException: java.lang.NullPointerException
>  at 
> org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
>  at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
> ...
> Caused by: java.lang.NullPointerException
>  at 
> org.apache.hadoop.hbase.rest.NamespacesInstanceResource.createOrUpdate(NamespacesInstanceResource.java:250)
>  at 
> org.apache.hadoop.hbase.rest.NamespacesInstanceResource.processUpdate(NamespacesInstanceResource.java:243)
>  at 
> org.apache.hadoop.hbase.rest.NamespacesInstanceResource.post(NamespacesInstanceResource.java:183)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:498)
>  at 
> org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
>  at 
> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
>  at 
> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to