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

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

    XMLWordPrintable

Details

    • Hide
         public static final class MyFeature implements Feature {
      
            @Override
            public boolean configure(FeatureContext featureContext) { 
               
                featureContext.register(new MyFilter());
                featureContext.register(new MyFilter()); //Should be rejected at runtime
                return true;
            }
      
        }
      
        public static final class MyFilter implements ClientRequestFilter {
      
            @Override
            public void filter(ClientRequestContext clientRequestContext) throws IOException {
                System.out.println(MyFilter.class.getName());
            }
      
        }
      
        @Test
        public void test() {
            Client client = ClientBuilder.newClient();
            try {
                WebTarget webTarget = client.target("http://www.changeit.com");
                webTarget.register(MyFeature.class).request().get();
            }
      
            finally {
                client.close();
            }
      
        }
      
      Show
      public static final class MyFeature implements Feature { @Override public boolean configure(FeatureContext featureContext) { featureContext.register( new MyFilter()); featureContext.register( new MyFilter()); //Should be rejected at runtime return true ; } } public static final class MyFilter implements ClientRequestFilter { @Override public void filter(ClientRequestContext clientRequestContext) throws IOException { System .out.println(MyFilter. class. getName()); } } @Test public void test() { Client client = ClientBuilder.newClient(); try { WebTarget webTarget = client.target( "http: //www.changeit.com" ); webTarget.register(MyFeature.class).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. "

      Attachments

        Issue Links

          Activity

            People

              rsigal@redhat.com Ronald Sigal
              nicones Nicolas NESMON
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: