Details
-
Bug
-
Resolution: Done
-
Major
-
3.1.3.Final
-
None
-
None
Description
Creating a Java client for the CouchDB database, one of the JAX-RS methods is specified by the following interface:
@HEAD void exists(@PathParam("db") String db);
When this code is executed and the server returns a 200 (the requested database exists), the method passes control to the next line of code.
When the requested database does not exist, the server returns a 404 but the application throws the following NPE:
Exception in thread "main" java.lang.NullPointerException
at org.jboss.resteasy.util.ReadFromStream.readFromStream(ReadFromStream.java:30)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.bufferEntity(ClientResponse.java:322)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:48)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:107)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
at com.sun.proxy.$Proxy23.exists(Unknown Source)
at org.jcouchdb.Junk.main(Junk.java:45)
This method should instead throw a javax.ws.rs.NotFoundException indicating that the requested resource does not exist. Also note that if these method return Response instead of void, then the Response object's status code is correct. The @GET verb behaves as expected in both cases.