You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Ramkumar R <ra...@gmail.com> on 2008/05/29 10:10:27 UTC

Problem seen in Policy Processors

For creating an itests for the validation messages, it was a requirement to
reproduce all kind of exceptions thrown from various processors in the
runtime. I came across this issue of unreachable code in the policy
processors (especially in PolicyIntentProcessor.java and
PolicySetProcessor.java). Here is the piece of code from
resolveProfileIntent method of PolicyIntentProcessor.java to explain.....

for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
     if (requiredIntent.isUnresolved()) {
      Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
requiredIntent);
        if (resolvedRequiredIntent != null) {
           requiredIntents.add(resolvedRequiredIntent);
        } else {
          error("RequiredIntentNotFound", resolver, requiredIntent,
policyIntent);
          throw new ContributionResolveException("Required Intent - " +
requiredIntent
          + " not found for ProfileIntent "
             + policyIntent);
        }
    } else {
      requiredIntents.add(requiredIntent);
    }
  }

Here the resolver.resolveModel does not seem to return null in any case,
what happens is if the resolver is unable to resolve the model it just
returns the unresolved model. So the if condition checking for
resolvedRequiredIntent for null never fails and the later part of the code
in the else condition is never reached.

Similarly, there are 6 places (including the above said) where this kind of
issue is noticed, where the code is failing to throw the following
exceptions.....
ExcludedIntentNotFound
QualifiableIntentNotFound
RequiredIntentNotFound
ReferredPolicySetNotFound
MappedIntentNotFound
ProvidedIntentNotFound

To overcome this situation, i just tried modifying the code to look like
this and it seems to be working for me.

Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
requiredIntent);
if (!resolvedRequiredIntent.isUnresolved()) {
     requiredIntents.add(resolvedRequiredIntent);
} else {
   error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
    throw new ContributionResolveException("Required Intent - " +
requiredIntent
                                                                     + " not
found for ProfileIntent "
                                                                     +
policyIntent);
}

Like to take help from someone, to know if this is really an issue that i am
noticing OR did i just overlook at the code.
If its really an issue, can i raise a JIRA to fix this. Thanks.

-- 
Thanks & Regards,
Ramkumar Ramalingam

Re: Problem seen in Policy Processors

Posted by Ramkumar R <ra...@gmail.com>.
As explained in my previous post, after introducing a fix as shown below

Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
requiredIntent);
if (!resolvedRequiredIntent.isUnresolved()) {
     requiredIntents.add(resolvedRequiredIntent);

for the unreachable code, noticed that not always this condition holds good
to validate. The above fix holds good if all the simple intents were defined
at the top of the definitions.xml as shown below.

<!-- simple intent -->
<intent name="confidentiality" constrains="sca:binding"></intent>
<intent name="integrity" constrains="sca:binding"></intent><intent
name="messageProtection" constrains="sca:binding"
requires="test:confidentiality test:integrity">
</intent>

Instead when the simple intents are placed at the bottom of the
definitions.xml as shown below,

<intent name="messageProtection" constrains="sca:binding"
requires="test:confidentiality test:integrity">
</intent>
<!-- simple intent -->
<intent name="confidentiality" constrains="sca:binding"></intent>
<intent name="integrity" constrains="sca:binding"></intent>

then the code does not seem to work as required. This is because
SCADefinitionsProcessor.java tries to resolve the policies in the order as
it was read. I believe this should not happen and needs a rewriting for
resolving the policies.

Can anyone suggest if this is the right approach?

-- 
Thanks & Regards,
Ramkumar Ramalingam

Re: Problem seen in Policy Processors

Posted by Ramkumar R <ra...@gmail.com>.
I have opened TUSCANY-2354 to fix this issue.

On 5/30/08, Ramkumar R <ra...@gmail.com> wrote:
>
> After doing a complete debug of the code, realized that this seems to be an
> issue and we need a fix here.
>
> I will be opening a JIRA to fix this.
>
>  On 5/29/08, Ramkumar R <ra...@gmail.com> wrote:
>>
>> For creating an itests for the validation messages, it was a requirement
>> to reproduce all kind of exceptions thrown from various processors in the
>> runtime. I came across this issue of unreachable code in the policy
>> processors (especially in PolicyIntentProcessor.java and
>> PolicySetProcessor.java). Here is the piece of code from
>> resolveProfileIntent method of PolicyIntentProcessor.java to explain.....
>>
>> for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
>>      if (requiredIntent.isUnresolved()) {
>>       Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
>> requiredIntent);
>>         if (resolvedRequiredIntent != null) {
>>            requiredIntents.add(resolvedRequiredIntent);
>>         } else {
>>           error("RequiredIntentNotFound", resolver, requiredIntent,
>> policyIntent);
>>           throw new ContributionResolveException("Required Intent - " +
>> requiredIntent
>>           + " not found for ProfileIntent "
>>              + policyIntent);
>>         }
>>     } else {
>>       requiredIntents.add(requiredIntent);
>>     }
>>   }
>>
>> Here the resolver.resolveModel does not seem to return null in any case,
>> what happens is if the resolver is unable to resolve the model it just
>> returns the unresolved model. So the if condition checking for
>> resolvedRequiredIntent for null never fails and the later part of the code
>> in the else condition is never reached.
>>
>> Similarly, there are 6 places (including the above said) where this kind
>> of issue is noticed, where the code is failing to throw the following
>> exceptions.....
>> ExcludedIntentNotFound
>> QualifiableIntentNotFound
>> RequiredIntentNotFound
>> ReferredPolicySetNotFound
>> MappedIntentNotFound
>> ProvidedIntentNotFound
>>
>> To overcome this situation, i just tried modifying the code to look like
>> this and it seems to be working for me.
>>
>> Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
>> requiredIntent);
>> if (!resolvedRequiredIntent.isUnresolved()) {
>>      requiredIntents.add(resolvedRequiredIntent);
>> } else {
>>    error("RequiredIntentNotFound", resolver, requiredIntent,
>> policyIntent);
>>     throw new ContributionResolveException("Required Intent - " +
>> requiredIntent
>>                                                                      + "
>> not found for ProfileIntent "
>>                                                                      +
>> policyIntent);
>> }
>>
>> Like to take help from someone, to know if this is really an issue that i
>> am noticing OR did i just overlook at the code.
>> If its really an issue, can i raise a JIRA to fix this. Thanks.
>>
>> --
>> Thanks & Regards,
>> Ramkumar Ramalingam
>>
>
>
>
> --
> Thanks & Regards,
> Ramkumar Ramalingam




-- 
Thanks & Regards,
Ramkumar Ramalingam

Re: Problem seen in Policy Processors

Posted by Ramkumar R <ra...@gmail.com>.
After doing a complete debug of the code, realized that this seems to be an
issue and we need a fix here.

I will be opening a JIRA to fix this.

On 5/29/08, Ramkumar R <ra...@gmail.com> wrote:
>
> For creating an itests for the validation messages, it was a requirement to
> reproduce all kind of exceptions thrown from various processors in the
> runtime. I came across this issue of unreachable code in the policy
> processors (especially in PolicyIntentProcessor.java and
> PolicySetProcessor.java). Here is the piece of code from
> resolveProfileIntent method of PolicyIntentProcessor.java to explain.....
>
> for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
>      if (requiredIntent.isUnresolved()) {
>       Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
> requiredIntent);
>         if (resolvedRequiredIntent != null) {
>            requiredIntents.add(resolvedRequiredIntent);
>         } else {
>           error("RequiredIntentNotFound", resolver, requiredIntent,
> policyIntent);
>           throw new ContributionResolveException("Required Intent - " +
> requiredIntent
>           + " not found for ProfileIntent "
>              + policyIntent);
>         }
>     } else {
>       requiredIntents.add(requiredIntent);
>     }
>   }
>
> Here the resolver.resolveModel does not seem to return null in any case,
> what happens is if the resolver is unable to resolve the model it just
> returns the unresolved model. So the if condition checking for
> resolvedRequiredIntent for null never fails and the later part of the code
> in the else condition is never reached.
>
> Similarly, there are 6 places (including the above said) where this kind of
> issue is noticed, where the code is failing to throw the following
> exceptions.....
> ExcludedIntentNotFound
> QualifiableIntentNotFound
> RequiredIntentNotFound
> ReferredPolicySetNotFound
> MappedIntentNotFound
> ProvidedIntentNotFound
>
> To overcome this situation, i just tried modifying the code to look like
> this and it seems to be working for me.
>
> Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class,
> requiredIntent);
> if (!resolvedRequiredIntent.isUnresolved()) {
>      requiredIntents.add(resolvedRequiredIntent);
> } else {
>    error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
>     throw new ContributionResolveException("Required Intent - " +
> requiredIntent
>                                                                      + "
> not found for ProfileIntent "
>                                                                      +
> policyIntent);
> }
>
> Like to take help from someone, to know if this is really an issue that i
> am noticing OR did i just overlook at the code.
> If its really an issue, can i raise a JIRA to fix this. Thanks.
>
> --
> Thanks & Regards,
> Ramkumar Ramalingam
>



-- 
Thanks & Regards,
Ramkumar Ramalingam