[Jersey-issues] [JIRA] Created: (JERSEY-1704) Providers.getMessageBodyWriter() throws NPE when annotations argument is null

  • From: "jan.supol (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [Jersey-issues] [JIRA] Created: (JERSEY-1704) Providers.getMessageBodyWriter() throws NPE when annotations argument is null
  • Date: Tue, 5 Feb 2013 18:53:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated

Providers.getMessageBodyWriter() throws NPE when annotations argument is null
-----------------------------------------------------------------------------

                 Key: JERSEY-1704
                 URL: http://java.net/jira/browse/JERSEY-1704
             Project: jersey
          Issue Type: Bug
          Components: core
    Affects Versions: 2.0-m12
            Reporter: jan.supol
            Priority: Blocker
             Fix For: 2.0-unplanned


javadoc says:
{quote}
annotations - an array of the annotations on the declaration of the artifact 
that will be written. E.g. if the message body is to be produced from a 
field, this will be the annotations on that field returned by 
Field.getDeclaredAnnotations.
{quote}
Obviously, Field.getDeclaredAnnotations can be null.
But, as Jersey contains EntityMessageWriter provider, which tries to get path 
value, and AbstractMessageBodyRW does not check for null annotations, this 
throws NPE. 

code:
{code:java}
@Path("resource")
public class Resource {
        @Context
        Providers providers;

        @GET
        @Path("isRegisteredWriterWildcard")
        public Response isRegisteredWriterWildCard() {
                MessageBodyWriter<ReadableWritableEntity> writer;
                writer = 
providers.getMessageBodyWriter(ReadableWritableEntity.class,
                                null, null, MediaType.WILDCARD_TYPE);
                Status status = entity == null ? Status.NOT_ACCEPTABLE : 
Status.OK;
                return Response.status(status).build();
        }
}
public class ReadableWritableEntity {
}
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[Jersey-issues] [JIRA] Created: (JERSEY-1704) Providers.getMessageBodyWriter() throws NPE when annotations argument is null

jan.supol (JIRA) 02/05/2013

[Jersey-issues] [JIRA] Resolved: (JERSEY-1704) Providers.getMessageBodyWriter() throws NPE when annotations argument is null

jan.supol (JIRA) 02/06/2013

[Jersey-issues] [JIRA] Updated: (JERSEY-1704) Providers.getMessageBodyWriter() throws NPE when annotations argument is null

Pavel Bucek (JIRA) 02/26/2013
Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150226.965aeb8)
 
 
Close
loading
Please Confirm
Close