[ 
https://issues.apache.org/jira/browse/IMPERIUS-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Wood updated IMPERIUS-23:
-------------------------------

    Description: 
The following simple policy when parsed causes a hang, which I believe is an 
infinite loop (see below):

Import Class java.util.Properties:prop;
Strategy Execute_All_Applicable;
Policy 
{
        Condition 
        {  
           1 == 1 && prop.getProperty("foo","bar").equals("foo")
        }
        Decision 
        {   
                prop.getProperty("foo")
        }
}:1;

I found a loop in PrimaryExpression.validate() that may not always execute an 
Iterator.next() as follows:

                while(identTupleIt.hasNext())
                {
                        if(returnType.getType() == TypeConstants.referenceType)
                        {
                                String referenceTypeName = 
returnType.getReferenceTypeName();
                                IdentPrimaryTuple ipt = 
(IdentPrimaryTuple)identTupleIt.next();
                                if(i++ == 0) // first element in the list has 
the same symbol table
                                { // as the primary expression
                                        ipt.setSymbolTable(_symTab);
                                }
                                returnType = ipt.validate(referenceTypeName);
                        } else {
                                identTupleIt.next();    // <--- Added by dawood
                        }
                        
                        
                }

However, this then causes the following exception....

Mar 3, 2009 4:35:43 PM 
org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
SEVERE: main validation error: 
org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type 
passed in.
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser 
expr
SEVERE: main TreeParser::Exception creating Expression at line 7 : validation 
error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong 
data type passed in.
 validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd 
has wrong data type passed in.
Number of Formal and passed parameters don't match for method getProperty
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl 
parseFile
SEVERE: Error encountered while parsing tree
Exception in thread "main" 
org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while 
parsing tree
        at 
org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
        at 
org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
        at 
com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
        at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

  was:
The following simple policy when parsed causes a hang, which I believe is an 
infinity look (see below):

Import Class java.util.Properties:prop;
Strategy Execute_All_Applicable;
Policy 
{
        Condition 
        {  
           1 == 1 && prop.getProperty("foo","bar").equals("foo")
        }
        Decision 
        {   
                prop.getProperty("foo")
        }
}:1;

I found a look in PrimaryExpression.validate() that may not always execute an 
Iterator.next() as follows:

                while(identTupleIt.hasNext())
                {
                        if(returnType.getType() == TypeConstants.referenceType)
                        {
                                String referenceTypeName = 
returnType.getReferenceTypeName();
                                IdentPrimaryTuple ipt = 
(IdentPrimaryTuple)identTupleIt.next();
                                if(i++ == 0) // first element in the list has 
the same symbol table
                                { // as the primary expression
                                        ipt.setSymbolTable(_symTab);
                                }
                                returnType = ipt.validate(referenceTypeName);
                        } else {
                                identTupleIt.next();    // <--- Added by dawood
                        }
                        
                        
                }

However, this then causes the following exception....

Mar 3, 2009 4:35:43 PM 
org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
SEVERE: main validation error: 
org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type 
passed in.
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser 
expr
SEVERE: main TreeParser::Exception creating Expression at line 7 : validation 
error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong 
data type passed in.
 validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd 
has wrong data type passed in.
Number of Formal and passed parameters don't match for method getProperty
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl 
parseFile
SEVERE: Error encountered while parsing tree
Exception in thread "main" 
org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while 
parsing tree
        at 
org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
        at 
org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
        at 
com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
        at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)


> Infinite loop, and then parse error.
> ------------------------------------
>
>                 Key: IMPERIUS-23
>                 URL: https://issues.apache.org/jira/browse/IMPERIUS-23
>             Project: Imperius
>          Issue Type: Bug
>         Environment: Windows, Java 1.5.
>            Reporter: David Wood
>            Assignee: Bill Stoddard
>
> The following simple policy when parsed causes a hang, which I believe is an 
> infinite loop (see below):
> Import Class java.util.Properties:prop;
> Strategy Execute_All_Applicable;
> Policy 
> {
>       Condition 
>       {  
>          1 == 1 && prop.getProperty("foo","bar").equals("foo")
>       }
>       Decision 
>       {   
>               prop.getProperty("foo")
>       }
> }:1;
> I found a loop in PrimaryExpression.validate() that may not always execute an 
> Iterator.next() as follows:
>               while(identTupleIt.hasNext())
>               {
>                       if(returnType.getType() == TypeConstants.referenceType)
>                       {
>                               String referenceTypeName = 
> returnType.getReferenceTypeName();
>                               IdentPrimaryTuple ipt = 
> (IdentPrimaryTuple)identTupleIt.next();
>                               if(i++ == 0) // first element in the list has 
> the same symbol table
>                               { // as the primary expression
>                                       ipt.setSymbolTable(_symTab);
>                               }
>                               returnType = ipt.validate(referenceTypeName);
>                       } else {
>                               identTupleIt.next();    // <--- Added by dawood
>                       }
>                       
>                       
>               }
> However, this then causes the following exception....
> Mar 3, 2009 4:35:43 PM 
> org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
> SEVERE: main validation error: 
> org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data 
> type passed in.
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser 
> expr
> SEVERE: main TreeParser::Exception creating Expression at line 7 : validation 
> error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong 
> data type passed in.
>  validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd 
> has wrong data type passed in.
> Number of Formal and passed parameters don't match for method getProperty
> Mar 3, 2009 4:35:43 PM 
> org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
> SEVERE: Error encountered while parsing tree
> Exception in thread "main" 
> org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered 
> while parsing tree
>       at 
> org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
>       at 
> org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
>       at 
> com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
>       at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to