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

JAX-RS component must not be registered more than once on javax.ws.rs.core.Configurable instances

    Details

    • Steps to Reproduce:
      Hide

      public class ProviderRegistrationTest {

      public static class MyFeature implements Feature {

      @Override
      public boolean configure(FeatureContext featureContext)

      { // MyFilter instance will be registered third on the same // featureContext even if // featureContext.getConfiguration().isRegistered(MyFilter.class)==true featureContext.register(new MyFilter()); return true; }

      }

      public static class MyFilter implements ClientRequestFilter {

      @Override
      public void filter(ClientRequestContext clientRequestContext) throws IOException

      { System.out.println(MyFilter.class.getName()); }

      }

      public static void main(String[] args) {
      Client client = ClientBuilder.newClient();
      try

      { WebTarget webTarget = client .target("http://www.changeit.com"); // MyFeature will be registered third on the same webTarget even if // webTarget.getConfiguration().isRegistered(MyFeature.class)==true webTarget.register(MyFeature.class).register(new MyFeature()).register(new MyFeature()).request().get(); }

      finally

      { client.close(); }

      }

      }

      Show
      public class ProviderRegistrationTest { public static class MyFeature implements Feature { @Override public boolean configure(FeatureContext featureContext) { // MyFilter instance will be registered third on the same // featureContext even if // featureContext.getConfiguration().isRegistered(MyFilter.class)==true featureContext.register(new MyFilter()); return true; } } public static class MyFilter implements ClientRequestFilter { @Override public void filter(ClientRequestContext clientRequestContext) throws IOException { System.out.println(MyFilter.class.getName()); } } public static void main(String[] args) { Client client = ClientBuilder.newClient(); try { WebTarget webTarget = client .target("http://www.changeit.com"); // MyFeature will be registered third on the same webTarget even if // webTarget.getConfiguration().isRegistered(MyFeature.class)==true webTarget.register(MyFeature.class).register(new MyFeature()).register(new MyFeature()).request().get(); } finally { client.close(); } } }

      Description

      According to JAXRS specification : "As a general rule, for each JAX-RS component class there can be at most one registration — class-based or instance-based — configured at any given moment. Implementations MUST reject any attempts to configure a new registration for a provider class that has been already registered in the given configurable context earlier. Implementations SHOULD also raise a warning to inform the user about the rejected component registration. "

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ron_sigal Ronald Sigal
                  Reporter:
                  nicolas.n Nicolas NESMON
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: