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

Subresource with unbound type parameter throws exception: Unable to resolve type variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 3.0-beta-5
    • 2.3.3.Final
    • jaxrs
    • None
    • Hide

      Just add '{}' to end of object declaration so that resteasy can get at
      the generic type.

      @Override
      public SubImpl<Integer> getSub(String path)
      {
         return new SubImpl<Integer>(path){};
      }
      
      Show
      Just add '{}' to end of object declaration so that resteasy can get at the generic type. @Override public SubImpl< Integer > getSub( String path) { return new SubImpl< Integer >(path){}; }

      org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Unable to resolve type variable

      Testcase:

      public class ParameterizedSubResourceTest
      {
      private static Dispatcher dispatcher;

      @BeforeClass
      public static void before() throws Exception

      { dispatcher = EmbeddedContainer.start().getDispatcher(); dispatcher.getRegistry().addPerRequestResource(RootImpl.class); }

      @AfterClass
      public static void after() throws Exception

      { EmbeddedContainer.stop(); }

      public static interface Root
      {
      @Path("sub/

      {path}

      ")
      public Sub getSub(@PathParam("path") String path);
      }

      public static interface Sub

      { @GET @Produces("text/plain") public String get(); }

      public static interface InternalInterface<T extends Number>

      { @PUT void foo(T value); }

      @Path("/path")
      public static class RootImpl implements Root
      {
      @Override
      public SubImpl<Integer> getSub(String path)

      { return new SubImpl<Integer>(path); }

      }

      public static class SubImpl<T extends Number> implements Sub, InternalInterface<T>
      {
      private final String path;

      public SubImpl(String path)

      { this.path = path; }

      @Override
      public String get()

      { return "Boo! - " + path; }

      @Override
      public void foo(T value)

      { System.out.println("foo: " + value); }

      }

      @Test
      public void test()
      {
      ClientRequest request = new ClientRequest(generateURL("/path/sub/fred"));
      ClientResponse<String> response = null;
      try

      { response = request.get(String.class); Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus()); Assert.assertEquals("Boo! - fred", response.getEntity()); }

      catch (Exception e)

      { throw new RuntimeException(e); }

      }
      }

              patriot1burke@gmail.com Bill Burke (Inactive)
              shanedav Shane D (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: