Bug 1328948

Summary: Scripts with "||" are incorrectly saved (Unable to build projects that contain process using OR (II) operator in ON ENTRY/EXIT fields)
Product: [Retired] JBoss BPMS Platform 6 Reporter: Amana <ajuricic>
Component: jBPM DesignerAssignee: Tihomir Surdilovic <tsurdilo>
Status: CLOSED EOL QA Contact: Kirill Gaevskii <kgaevski>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: ajuricic, smcgowan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:39:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
TestProcess none

Description Amana 2016-04-20 17:04:44 UTC
Description of problem:
It seems like it is not possible to make use of || (OR) operator in ON ENTRY/ ON EXIT fields for User Tasks, for instance. The project containing the business process fails to build with the following error message:

10:24:28,574 ERROR [org.drools.compiler.kie.builder.impl.AbstractKieModule] (http-/0.0.0.0:8080-1) Unable to build KieBaseModel:defaultKieBase
Unable to determine the used declarations.
java.lang.NullPointerException : Process org.jbpm.TestProcess(TestProject.TestProcess)
java.lang.NullPointerException
Process Compilation error : Process org.jbpm.TestProcess(TestProject.TestProcess)
	org/jbpm/Process_org$u46$jbpm$u46$TestProcess1299745802.java (16:618) : Syntax error on token ")", : expected
...

If || is changed to && it builds properly. 

Version-Release number of selected component (if applicable):
Reproduced in BPM Suite 6.1.0 and 6.2.2

How reproducible:
Always

Steps to Reproduce:
1. create a simple HT process as follows:
   Start Event -> User Task -> End Event
2. Set a process variable such as: a -> String
3. In the User Task -> On Exit field, add a script like:

if ( a == null || a ) {
    System.out.println("print");
}

4. save the process
5. try to build the project.

Actual results:
The error will be thrown.

Expected results:
It should build properly.

Additional info:
If changing the code to:

if ( a == null && a ) {
    System.out.println("print");
}

it builds.

Comment 1 Amana 2016-04-20 17:06:23 UTC
Created attachment 1149146 [details]
TestProcess

Comment 2 Amana 2016-04-20 17:07:08 UTC
hi all,

I attached a simple test process to reproduce the issue easier.

Are we missing something here or is it really a bug?

Thanks in advance!

Comment 4 Marco Rietveld 2016-04-29 13:17:28 UTC
Amana, 

This looks like it might be a designer issue: 

When I look at the BPMN2 definition that you attached, I'm seeing the following: 

        <drools:onExit-script scriptFormat="http://www.java.com/java">
          <drools:script><![CDATA[if ( b == null ]]></drools:script>
        </drools:onExit-script>
        <drools:onExit-script scriptFormat="http://www.java.com/java">
          <drools:script><![CDATA[]]></drools:script>
        </drools:onExit-script>
        <drools:onExit-script scriptFormat="http://www.java.com/java">
          <drools:script><![CDATA[!b ) {
    System.out.println("print");
}]]></drools:script>

This is, (as far as I know?), not a valid script. 

Could you confirm that you created this BPMN2 file via designer? And also, that you added "if ( b == null || !b ) { System.out.println("print"); }" in designer as the onExit script? 

Thanks!

Comment 5 Amana 2016-04-29 13:27:33 UTC
Hi Marco,

It is actually the customer process... but I have the same behaviour if trying to create a new process in business central using similar script with Boolean or String process variables...

Thanks

Comment 6 Marco Rietveld 2016-04-29 14:54:13 UTC
Tiho (or Jeremy), it looks like Designer is incorrectly parsing the "||" signs when it adds a script. 

Would you mind taking a look?

Comment 7 Tihomir Surdilovic 2016-04-29 16:19:11 UTC
Marco, yes I'm on it. thanks