jersey
  1. jersey
  2. JERSEY-1507

Standard providers for java.lang.Boolean, java.lang.Character, java.lang.Number does not work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-m09
    • Fix Version/s: 2.0-m10
    • Component/s: core
    • Labels:
      None

      Description

      @Path("resource")
      public class Resource {
      	@Path("number")
      	@POST
      	@Consumes(MediaType.TEXT_PLAIN)
      	@Produces(MediaType.TEXT_PLAIN)
      	public Number number(Number number){
      		return number;
      	}
      
      	@Path("boolean")
      	@POST
      	@Consumes(MediaType.TEXT_PLAIN)
      	@Produces(MediaType.TEXT_PLAIN)
      	public Boolean bigbool(Boolean bool){
      		return bool;		
      	}
      	@Path("character")
      	@POST
      	@Consumes(MediaType.TEXT_PLAIN)
      	@Produces(MediaType.TEXT_PLAIN)
      	public Character character(Character character){
      		return character;
      	}
      
      }
      
      ...
      Invocation.Builder builder = webtarget.request(MediaType.TEXT_PLAIN_TYPE);
      Invocation i = builder.build("POST",Entity.entity(new Boolean(true), MediaType.TEXT_PLAIN_TYPE));
      i.invoke();
      

      returns:

      << 415 UNSUPPORTED_MEDIA_TYPE

      spec says:

      java.lang.Boolean, java.lang.Character, java.lang.Number Only for text/plain. Corresponding
      primitive types supported via boxing/unboxing conversion.

      Note that primitive types work.

      Also, for BigDecimal (which is Number as well) The following message prints out:

      Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=tex
      t/plain, type=class java.math.BigDecimal, genericType=class java.math.BigDecimal.
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:219)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:163)
      at org.glassfish.jersey.message.internal.ExceptionWrapperInterceptor.aroundWriteTo(ExceptionWrapperInterceptor.java:79)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:163)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:825)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:815)
      at org.glassfish.jersey.client.RequestWriter.writeRequestEntity(RequestWriter.java:240)
      at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:213)
      at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:136)
      at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:208)

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 2 hours
              2h