jersey
  1. jersey
  2. JERSEY-1712

A MessageBodyReader is not instantiated, no error provided

    Details

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

      Description

      Spec. Section 4.1.2 says:

      If more than one public constructor can be used then an implementation MUST use the one with the most parameters

      My provider :

      @Provider
      public class StringReader implements MessageBodyReader<String> {
      	private HttpHeaders headers;
      	private UriInfo info;
      	private Application application;
      	private Request request;
      	private Providers provider;
      
      	protected StringReader(@Context HttpHeaders headers, @Context UriInfo info,
      			@Context Application application, @Context Request request,
      			@Context Providers provider) {
      		super();
      		this.headers = headers;
      		this.info = info;
      		this.application = application;
      		this.request = request;
      		this.provider = provider;
      	}
      
      	public StringReader(@Context HttpHeaders headers, @Context UriInfo info,
      			@Context Application application, @Context Request request) {
      		super();
      		this.headers = headers;
      		this.info = info;
      		this.application = application;
      		this.request = request;
      	}
      
      	public StringReader(@Context HttpHeaders headers, @Context UriInfo info,
      			@Context Application application) {
      		super();
      		this.headers = headers;
      		this.info = info;
      		this.application = application;
      	}
      
      	public StringReader(@Context HttpHeaders headers, @Context UriInfo info) {
      		super();
      		this.headers = headers;
      		this.info = info;
      	}
      
      	public StringReader(@Context HttpHeaders headers) {
      		super();
      		this.headers = headers;
      	}
      
      	@Override
      	public boolean isReadable(Class<?> type, Type genericType,
      			Annotation[] annotations, MediaType mediaType) {
      		return type == String.class;
      	}
      
      	@Override
      	public String readFrom(Class<String> type, Type genericType,
      			Annotation[] annotations, MediaType mediaType,
      			MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
      			throws IOException, WebApplicationException {
      		return "111";
      	}
      }
      
      @Path("resource")
      public class Resource {
      
      	@POST
      	public String echo(String entity) {
      		return entity;
      	}
      
      }
      

      A posted entity is echoed, not 111, and MessageBodyFactory#_getMessageBodyReader does not seem to have the provider in the mbrLookupCache, no error in any log provided.

        Issue Links

          Activity

          Hide
          jan.supol added a comment -

          It's likely JERSEY-1529 will fix this issue, although JERSEY-1529 reports Resources and this reports Providers

          Show
          jan.supol added a comment - It's likely JERSEY-1529 will fix this issue, although JERSEY-1529 reports Resources and this reports Providers

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes Time Not Required
                30m