Bug 1025324 - WebServiceWorkItemHandler cannot call operations with more than 1 parameter
Summary: WebServiceWorkItemHandler cannot call operations with more than 1 parameter
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ER5
: 6.0.0
Assignee: Maciej Swiderski
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-31 13:40 UTC by Ivo Bek
Modified: 2014-08-06 20:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:12:11 UTC
Type: Bug


Attachments (Terms of Use)

Description Ivo Bek 2013-10-31 13:40:46 UTC
Description of problem:

I just wanted to call an add operation for calculator which requires 2 parameters, x and y. http://soaptest.parasoft.com/calculator.wsdl
First I tried to set an array of parameters for web service operation through the process variable and it didn't work https://bugzilla.redhat.com/show_bug.cgi?id=1024946 . So I've changed it to set the variable in script task like this:
kcontext.setVariable("parameters", new Float[]{9.0f, 12.0f});
When I run it, it will throw java.lang.ClassCastException: [Ljava.lang.Float; cannot be cast to java.lang.Float
on the line https://github.com/droolsjbpm/jbpm/blob/master/jbpm-workitems/src/main/java/org/jbpm/process/workitem/webservice/WebServiceWorkItemHandler.java#L92
When I change the set variable command to use just one float, it will fail with java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 which is obvious because it requires 2 parameters.

The problem is that you consider parameter to be something of type Object https://github.com/droolsjbpm/jbpm/blob/master/jbpm-workitems/src/main/java/org/jbpm/process/workitem/webservice/WebServiceWorkItemHandler.java#L81 but an array cannot be used like an object - if you run the example below it will print [Ljava.lang.Float;@39c931fb
instead of 
9.0
12.0

public static void main(String[] args) {
    Object o = new Float[]{9.0f, 12.0f};
    test(o);
}
    
public static void test(Object... array) {
    for (Object o : array) {
        System.out.println(o);
    }
}

so I recommend to change the call to something like:
if (o instanceof Object[]) {
    test((Object[])o);
} else {
    test(o);
}

Comment 2 Maciej Swiderski 2013-11-09 19:13:55 UTC
fixed to support both Object[] and arrays of primitives

jbpm
master:
https://github.com/droolsjbpm/jbpm/commit/83cc7e669ee57357a8160b9a91e2454f88192b76

6.0.x:
https://github.com/droolsjbpm/jbpm/commit/5183d286a73db5874d967e1b49b408f4ac0595c2

Comment 3 Ivo Bek 2013-12-05 14:41:39 UTC
Verified in BPMS 6.0.0.ER5


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