Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004649 [Resin] minor always 07-01-11 13:22 07-05-11 09:50
Reporter reza View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.19
Summary 0004649: Using InjectionPoint effects bean resolution for Producers
Description Using InjectionPoint incorrectly effects bean resolution for Producers. It appears that Producers with InjectionPoints are given higher priority over Producers without InjectionPoints. In the following example, the BarBean is resolved for injection when FooBean should be resolved:

================================================================================
@WebServlet(urlPatterns = { "/" })
public class TestServlet extends HttpServlet {
  @Inject
  private TestBean bean;

  protected void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    
    writer.println(bean.getData());

    writer.close();
  }
}
================================================================================

================================================================================
@Entity
public interface TestBean {
  public String getData();
}
================================================================================

================================================================================
public class FooBean implements TestBean {
  @Override
  public String getData() {
    return "foo";
  }
}
================================================================================

================================================================================
public class BarBean implements TestBean {
  @Override
  public String getData() {
    return "bar";
  }
}
================================================================================

================================================================================
@Qualifier
@Retention(RUNTIME)
@Target({ METHOD, FIELD, PARAMETER, TYPE })
public @interface BarQualifier {
}
================================================================================

================================================================================
public class TestBeanFactory {

  @Produces
  public TestBean getFoo() {
    return new FooBean();
  }

  @Produces
  @BarQualifier
  public TestBean getBar(InjectionPoint injectionPoint) {
    return new BarBean();
  }
}
================================================================================

Injection resolves correctly if both producers have injection points:

================================================================================
public class TestBeanFactory {

  @Produces
  public TestBean getFoo(InjectionPoint injectionPoint) {
    return new FooBean();
  }

  @Produces
  @BarQualifier
  public TestBean getBar(InjectionPoint injectionPoint) {
    return new BarBean();
  }
}
================================================================================

Injection also resolves correctly if neither producers have injection points:

================================================================================
public class TestBeanFactory {

  @Produces
  public TestBean getFoo() {
    return new FooBean();
  }

  @Produces
  @BarQualifier
  public TestBean getBar() {
    return new BarBean();
  }
}
================================================================================

This issue was originally reported by Max Bureck: http://forum.caucho.com/showthread.php?t=27986. [^]
Additional Information
Attached Files

- Relationships

- Notes
(0005348)
ferg
07-05-11 09:50

ioc/0775
 

- Issue History
Date Modified Username Field Change
07-01-11 13:22 reza New Issue
07-05-11 09:50 ferg Note Added: 0005348
07-05-11 09:50 ferg Assigned To  => ferg
07-05-11 09:50 ferg Status new => closed
07-05-11 09:50 ferg Resolution open => fixed
07-05-11 09:50 ferg Fixed in Version  => 4.0.20


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker