Uploaded image for project: 'Wink'
  1. Wink
  2. WINK-311

Resource Locator's @PathParam resolution is not correct.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0
    • 1.1.2
    • Server
    • None
    • Recreated with a JUnit test.

    Description

      I have the following resource:

      @Path("/root")
      public static class TestApp {
      	private String name;
      	private TestApp child;
      
      	@GET
      	@Produces(MediaType.TEXT_PLAIN)
      	public String getNextChild() {
      		return child == null ? null : child.name;
      	}
      
      	@Path("{child}")
      	public Object getChild(@PathParam("child") String c) {
      		if (child != null && child.name.equals(c)) {
      			return child;
      			} else {
      				return new NotFound();
      			}
      		}
      	}
      }
      
      public static class NotFound {
      	@GET
      	public Response notFound() {
      		return Response.status(Status.NOT_FOUND).build();
      	}
      }
      

      Which is registered like this:

      @Override
      public Set<Object> getSingletons() {
      	Set<Object> set = new HashSet<Object>();
      	TestApp test1 = new TestApp("test1", new TestApp("level1", new TestApp("level2", new TestApp("level3", null))));
      	set.add(test1);
      	return set;
      }
      

      When I do GET: http://localhos/root/level1/level2/level3

      I get 404 File Not Found. The reason for this is because the "c" variable passed on the getChild method is always "level1" when it should change to "level2", "level3" after each call to getChild.

      Let me know if anything else is needed.

      Attachments

        1. RecursiveTreeTraversalTest.java
          4 kB
          Kaloyan Kolev

        Activity

          People

            bluk Bryant Luk
            kkolev Kaloyan Kolev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: