]
Soumitra Kumar commented on DROOLS-982:
---------------------------------------
This issue is reproducible with following testcase:
In DrlExprParserTest.java
public void testDrools982() throws Exception {
String source = "((((((((((((((((((((((((( a > 0
)))))))))))))))))))))))))";
ConstraintConnectiveDescr result = parser.parse( source );
assertFalse( parser.getErrors().toString(),
parser.hasErrors() );
}
DRL file with a rule having long LHS expression takes very long time
to parse
-----------------------------------------------------------------------------
Key: DROOLS-982
URL:
https://issues.jboss.org/browse/DROOLS-982
Project: Drools
Issue Type: Enhancement
Reporter: Soumitra Kumar
Assignee: Mark Proctor
My DRL file is:
package sk.rule.ruleset.r1;
import sk.event.Event;
// Event declaration
declare Event
@role(event)
@timestamp(time)
end
rule "Long LHS"
when
$event : Event ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (contains
("name", "foo") && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) )
then
// Empty
end
// Event definition
package sk.event
sealed case class Event (time: Long, map: Map [String, String]) {
def contains (key: String, value: String): Boolean = false
}
// Main class
package sk.apps
import java.io.File
import com.typesafe.scalalogging.LazyLogging
import org.kie.api.io.ResourceType
import org.kie.internal.io.ResourceFactory
import org.kie.internal.builder.KnowledgeBuilderFactory
object DrlParsing extends LazyLogging {
def main (args: Array [String]): Unit = {
logger.info (s"Starting KnowledgeBuilder")
val kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder ()
args.foreach { fileName =>
logger.info (s"Adding file $fileName")
kbuilder.add (ResourceFactory.newFileResource (new File (fileName)),
ResourceType.DRL)
}
if (kbuilder.hasErrors ())
logger.error (kbuilder.getErrors ().toString ())
}
}
The project URL is
https://github.com/soumitrak/drl-parsing