Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1671

NPE thrown when @HEAD method returns void

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.1.3.Final
    • Fix Version/s: 4.0.0.Beta1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Resteasy client with jackson2 and Java 1.8

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                rsearls R Searls
                Reporter:
                smoyer64 Steve Moyer
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: