Bug 1023204 - java.io.UTFDataFormatException while building BRMS package
java.io.UTFDataFormatException while building BRMS package
Status: ASSIGNED
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRM (Guvnor) (Show other bugs)
BRMS 5.3.1
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Mario Fusco
Lukáš Petrovický
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-24 17:16 EDT by Alessandro Lazarotti
Modified: 2013-10-29 12:33 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
server log (339.13 KB, text/x-log)
2013-10-24 17:16 EDT, Alessandro Lazarotti
no flags Details
repository containing a rule with many constraints (16.18 KB, application/zip)
2013-10-24 17:17 EDT, Alessandro Lazarotti
no flags Details

  None (edit)
Description Alessandro Lazarotti 2013-10-24 17:16:05 EDT
Created attachment 815930 [details]
server log

When a rule has thousands of constraints like:

~~~
when
          $frame: Frame($code :
code, (code == '0004422' || code == '0006439' ||
code == '0027203' || code == '0027214' || code ==
'0132077' || code == '0174002' || code == '0182704' ||
code == '0235761' || code == '0274720' || code ==
'0287580' || code == '0287580' || code == '0316581' ||
code == '0341710' || code == '0341895' || code ==
'0341969' || code == '0342218' || code == '0343501' ||
code == '0345035' || code == '0408284' || code ==
'0408284' || code == '0412490' || code == '0413158' ||
code == '0454492' || code == '0454492' || code ==
'0487948' || code == '0540528' || code == '0540528' || ... 
~~~


... its package can not be built by Guvnor:

~~~
java.io.UTFDataFormatException
       at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2134)
       at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:1977)
       at java.io.ObjectOutputStream.writeUTF(ObjectOutputStream.java:849)
       at org.drools.base.mvel.MVELCompilationUnit.writeExternal(MVELCompilationUnit.java:172)
       at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1429)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1398)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
       at org.drools.base.mvel.MVELPredicateExpression.writeExternal(MVELPredicateExpression.java:65)
(full log attached)
~~~

Steps to Reproduce:
It is just reproducible compiling the package by Guvnor. A sample repository containing a rule with several constraints is attached

Actual results:
The package is not built throwing the exception: java.io.UTFDataFormatException

Expected results:
Package built
Comment 1 Alessandro Lazarotti 2013-10-24 17:17:40 EDT
Created attachment 815931 [details]
repository containing a rule with many constraints
Comment 2 Edson Tirelli 2013-10-24 19:07:58 EDT
The stack trace hints at an Drools/MVEL serialization issue/limitation. Mario, can you take a look please?

org.drools.base.mvel.MVELCompilationUnit.writeExternal(MVELCompilationUnit.java:172)

Alessandro, regarding your question, I do think having a constraint with 2000 "or" conditions like this is bad, specially performance wise. I doubt this was manually created, so I assume they are using some kind of template based rule generation.

The alternative I see is to use a data structure to hold the list of codes and then have the constraint check that list of codes. If that fits their current solution/architecture I don't know.

E.g.: 

global java.util.Set setOfCodes

rule X
when
    Frame( code memberof setOfCodes )
then
...
Comment 3 Mario Fusco 2013-10-29 12:33:15 EDT
I didn't investigate the serialization problem, but I found another issue with mvel while parsing an expression with a few thousands constraints like this. Indeed after a given point (around 5k constraints) it throws an StackOverflowError and is no longer able to parse the expression.

Note You need to log in before you can comment on or make changes to this bug.