jersey
  1. jersey
  2. JERSEY-1704

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: 2.0-m12
    • Fix Version/s: 2.0-m13, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      javadoc says:

      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.

      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:

      @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 {
      }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: