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

DefaultValue for param is not processed before first request

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • None
    • 3.6.1.SP2, 3.6.2.Final
    • None
    • None

    Description

      DefaultValue for param is not processed before first request

      This is not a regression against RESTEasy 3.0.24.final or RESTEasy 3.0.16.Final

      According to the spec's javadoc:

       * By default, when used for injection of parameter values, a selected {@code ParamConverter}
       * instance MUST be used eagerly by a JAX-RS runtime to convert any {@link DefaultValue
       * default value} in the resource or provider model, that is during the application deployment,
       * before any value – default or otherwise – is actually required.
       * This conversion strategy ensures that any errors in the default values are reported
       * as early as possible.
      

      DefaultValue annotation can be used like this:

      @GET
      public String testQueryParam(@DefaultValue("INJECTED_ERROR{name=Default,age=42}") @QueryParam("param") ParamDummy param) {
      

      If fromString method of paramConverter class throws exception during the parsing of the default value, this is performed by each request, not before the first request. So previous spec's javadoc doc is violated:

      @Provider
      public class DummyParamConverterProvider implements ParamConverterProvider {
          @Override
          public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
              if (rawType.getName().equals(ParamDummy.class.getName())) {
                  return new ParamConverter<T>() {
                      @Override
                      public T fromString(String value) {
                          ...
                          throw new IllegalArgumentException("invalid string " + value);
                          ...
                      }
      
                      @Override
                      public String toString(T value) {
                          ...
                      }
                  };
              }
              return null;
          }
      }
      

      Btw, this behaviour can be changed by @ParamConverter.Lazy annotation, but this annotation is not used in RESTEasy code base at all.

      cc: msvehla@redhat.com, jbliznak@redhat.com, mstefank

      Attachments

        Issue Links

          Activity

            People

              rsearls r searls
              mkopecky@redhat.com Marek Kopecky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: