felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Vandemeulebrouck (JIRA)" <j...@apache.org>
Subject [jira] Created: (FELIX-2834) @Validate method is called when the @Requires components are not validated yet
Date Thu, 10 Feb 2011 10:47:57 GMT
@Validate method is called when the @Requires components are not validated yet

                 Key: FELIX-2834
                 URL: https://issues.apache.org/jira/browse/FELIX-2834
             Project: Felix
          Issue Type: Bug
          Components: iPOJO
    Affects Versions: iPOJO-1.6.0
            Reporter: Vincent Vandemeulebrouck

Declare two components one that requires the other.
Have an @Validate method.
Depending on the declaration order in the metadata.xml, the component that requires the other
may have acces to a component which has not been validated.


class Component1
  Component2 c2;

  public void init() {
    // this may cause an NullPointerException, as c2.usefullData is created in the @Validate
    if (c2.usefullData.length()>0) {
        // Do something

class Component2
  String usefullData;
  public void init() { usefullData="ready"; }

If you declare this metadata.xml, the @Validate will fail:
   <instance component="Component1" />
   <instance component="Component2" />

Changing the order of components in xml solves the problem, although I think the validation
should be called only when the required components are validated.

This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message