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

NPE thrown when @HEAD method returns void

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.0.0.Beta1, 3.5.0.CR1
    • 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.

      Attachments

        Activity

          People

            rsearls r searls
            smoyer64 Steve Moyer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: