'Passing http url in a rule throws exception in latest drools versions(v7.64 onwards)
When I am passing a http url in a rule(inside when condition), during "apply rule", drools engine is throwing an exception in latest drools versions(v7.64 onwards).
Error message: "Encountered Error during Apply Rules Execution.begin 0, end -1, length 138".
Can anyone please help me how to resolve this. I have provided the sample DRL rule below:
when
$e1 : Fact(path == \"Interaction\" , (String.valueOf(this.getElement(\"classHistory[0].class.where(system='http://domain/url/Code').exists()\")) == true))
then
...
Some Actions...
....
end
Inside "StringUtils.java" class of new drools versions(7.64 onwards) there is a method : "codeAwareIndexOf(String str, String searched)" where we can see the str taken as input is internally rearranged as "String.valueOf(this.getElement("classHistory[0].class.where(system='http://domain/url/Code').exists()")) == true".
we can see the back slash before double quotes are removed and this code does not allow "//" present in the http URL and that leads to its returns as "-1".
I have shared the screenshots of my debugging below:
1.
2.
3.
4.
And from the screenshots its visible that, as two funtions 1. isInQuotes( str, i ) and isInComment( str, i ) retuns true that leads to that particular error. In the screenshots internal implementation of these functions can be seen. And on the last screenshot, its visible that as the method "codeAwareIndexOf" returns -1, then java String class throws that above error message.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
