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 <[EMAIL PROTECTED]> 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