jersey
  1. jersey
  2. JERSEY-995

@DefaultValue does not work with @PathParam

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.12
    • Fix Version/s: 2.0-m08, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      Assume a resource
      @Path(value = "/PathParamTest")
      public class PathParamTest {

      @GET
      public String main(@DefaultValue("PathParamTest") @PathParam("id") String text)

      { return "TEXT:" + text; }

      }

      Calling that returns "TEXT:null".

      //---------------------------
      @Path(value = "/PathParamTest")
      public class PathParamTest {

      @Path("/x/

      {id}

      "
      @GET
      public String main(@DefaultValue("PathParamTest") @PathParam("id") String text)

      { return "TEXT:" + text; }

      }

      This does not work either : GET /PathParamTest/x/, nor GET /PathParamTest/x//.

        Activity

        Hide
        Martin Matula added a comment -

        Marek, should default value be applicable to path params?

        Show
        Martin Matula added a comment - Marek, should default value be applicable to path params?
        Hide
        Marek Potociar added a comment -

        The use-case above does not make any sense IMHO. This needs to be fixed in the spec. Moving the issue to the spec.

        Show
        Marek Potociar added a comment - The use-case above does not make any sense IMHO. This needs to be fixed in the spec. Moving the issue to the spec.
        Hide
        Marek Potociar added a comment -

        It is possible that with sub-resource methods, the Path template is specified on that method. Thus, for all other methods it makes sense to have a @DefaultValue annotation on a @PathParam for that path template, e.g.:

        @Path("foo")
        public class FooResource {
            @PathParam("id") @DefaultValue("baz") String id;
        
            @GET
            public String getFoo() {
                return id;
            }
        
            @GET
            @Path("bar/{id}")
            public String getBar() {
                return id;
            }
        }
        
        Show
        Marek Potociar added a comment - It is possible that with sub-resource methods, the Path template is specified on that method. Thus, for all other methods it makes sense to have a @DefaultValue annotation on a @PathParam for that path template, e.g.: @Path( "foo" ) public class FooResource {     @PathParam( "id" ) @DefaultValue( "baz" ) String id;     @GET     public String getFoo() {         return id;     }     @GET     @Path( "bar/{id}" )     public String getBar() {         return id;     } }

          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 - 3 hours
              3h
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 3 hours
              3h