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

SpringBeanProcessor does not warn about beans ambiguity

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.16.Final
    • Fix Version/s: None
    • Component/s: CDI Integration
    • Labels:

      Description

      SpringBeanProcessor does not detect and report ambiguity of beans that implement one interface when JAX-RS annotations are written on the interface.

      Here is an example. Interface Foo has 2 implementations:

      @Path("/foo")
      interface Foo {
          @GET public int foo();
      }
      
      @Service
      @Qualifier("one")
      public class FooOne implements Foo {
          public int foo() {return 1;}
      }
      
      @Service
      @Qualifier("two")
      public class FooTwo implements Foo {
          public int foo() {return 2;}
      }
      

      FooOne and FooTwo are both legal Spring beans that can successfully co-exist in one context and accessed by other beans that distinguish them using qualifier.

      However since annotation @Path is written on interface both beans are exposed by SpringBeanProcessor as REST web service. When relevant HTTP request is being processed one of these implementations are chosen semi-randomly.

      The choice actually is not done randomly but it depends on the order of beans deployment and therefore can depend on the application packaging, file system etc.

      In our particular case system stopped functioning correctly when we added absolutely orthogonal command line flag -XX:+AggressiveOpts

      I think that SpringBeanProcessor should at least warn or even better fail when such ambiguity is found.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            alexander_radzin Alexander Radzin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: