You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Vincent Vandemeulebrouck (JIRA)" <ji...@apache.org> on 2011/02/10 11:47:57 UTC
[jira] Created: (FELIX-2834) @Validate method is called when the
@Requires components are not validated yet
@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.
Example:
@Component
class Component1
{
@Requires
Component2 c2;
@Validate
public void init() {
// this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
if (c2.usefullData.length()>0) {
// Do something
}
}
}
@Component
class Component2
{
String usefullData;
@Validate
public void init() { usefullData="ready"; }
}
If you declare this metadata.xml, the @Validate will fail:
<ipojo>
<instance component="Component1" />
<instance component="Component2" />
</ipojo>
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
[jira] Assigned: (FELIX-2834) @Validate method is called when the
@Requires components are not validated yet
Posted by "Clement Escoffier (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Clement Escoffier reassigned FELIX-2834:
----------------------------------------
Assignee: Clement Escoffier
> @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
> Assignee: Clement Escoffier
> Labels: callback, metadata, require, validation
>
> 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.
> Example:
> @Component
> class Component1
> {
> @Requires
> Component2 c2;
> @Validate
> public void init() {
> // this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
> if (c2.usefullData.length()>0) {
> // Do something
> }
> }
> }
> @Component
> class Component2
> {
> String usefullData;
> @Validate
> public void init() { usefullData="ready"; }
> }
> If you declare this metadata.xml, the @Validate will fail:
> <ipojo>
> <instance component="Component1" />
> <instance component="Component2" />
> </ipojo>
> 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
[jira] Commented: (FELIX-2834) @Validate method is called when the
@Requires components are not validated yet
Posted by "Clement Escoffier (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12994917#comment-12994917 ]
Clement Escoffier commented on FELIX-2834:
------------------------------------------
How does c2 expose itself ? Is it a service ?
Because with:
@Component
class Component1
{
@Requires
Component2 c2;
@Validate
public void init() {
// this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
if (c2.usefullData.length()>0) {
System.out.println("Youhou " + c2.usefullData);
}
}
}
@Component
@Provides(specifications=Component2.class)
public class Component2
{
String usefullData;
@Validate
public void init() { usefullData="ready"; }
}
and this metadata:
<instance component="ipojo.test.org.apache.felix.ipojo.felix2834.Component1"/>
<instance component="ipojo.test.org.apache.felix.ipojo.felix2834.Component2"/>
I got the expected result:
Youhou ready
I'm using iPOJO 1.8.0.
> @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
> Assignee: Clement Escoffier
> Labels: callback, metadata, require, validation
>
> 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.
> Example:
> @Component
> class Component1
> {
> @Requires
> Component2 c2;
> @Validate
> public void init() {
> // this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
> if (c2.usefullData.length()>0) {
> // Do something
> }
> }
> }
> @Component
> class Component2
> {
> String usefullData;
> @Validate
> public void init() { usefullData="ready"; }
> }
> If you declare this metadata.xml, the @Validate will fail:
> <ipojo>
> <instance component="Component1" />
> <instance component="Component2" />
> </ipojo>
> 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
[jira] Resolved: (FELIX-2834) @Validate method is called when the
@Requires components are not validated yet
Posted by "Clement Escoffier (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Clement Escoffier resolved FELIX-2834.
--------------------------------------
Resolution: Won't Fix
Already fixed in the 1.8.0.
> @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
> Assignee: Clement Escoffier
> Labels: callback, metadata, require, validation
>
> 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.
> Example:
> @Component
> class Component1
> {
> @Requires
> Component2 c2;
> @Validate
> public void init() {
> // this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
> if (c2.usefullData.length()>0) {
> // Do something
> }
> }
> }
> @Component
> class Component2
> {
> String usefullData;
> @Validate
> public void init() { usefullData="ready"; }
> }
> If you declare this metadata.xml, the @Validate will fail:
> <ipojo>
> <instance component="Component1" />
> <instance component="Component2" />
> </ipojo>
> 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
[jira] Commented: (FELIX-2834) @Validate method is called when the
@Requires components are not validated yet
Posted by "Vincent Vandemeulebrouck (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995296#comment-12995296 ]
Vincent Vandemeulebrouck commented on FELIX-2834:
-------------------------------------------------
Thanks for the quick answer
As indicated in the "affects version", it was iPOJO-1.6.0
This might be solved in 1.8.0, I will see if we can upgrade.
Anyway, we have the workaround to prevent the issue (sorting the components in the metadata.xml).
Vincent
> @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
> Assignee: Clement Escoffier
> Labels: callback, metadata, require, validation
>
> 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.
> Example:
> @Component
> class Component1
> {
> @Requires
> Component2 c2;
> @Validate
> public void init() {
> // this may cause an NullPointerException, as c2.usefullData is created in the @Validate method
> if (c2.usefullData.length()>0) {
> // Do something
> }
> }
> }
> @Component
> class Component2
> {
> String usefullData;
> @Validate
> public void init() { usefullData="ready"; }
> }
> If you declare this metadata.xml, the @Validate will fail:
> <ipojo>
> <instance component="Component1" />
> <instance component="Component2" />
> </ipojo>
> 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