You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a process definition with a single service task activity, which is backed by a Java Delegate;
Add an input parameter mapping on Input/Output tab for an input variable, using ${0} as the Variable Assignment Value expression;
In your code, create a variable factory for the variable defined on step 2 using CamundaBpmDataKotlin.longVariable method;
In the delegate code, which is called by the task defined on step 1, create a piece of code, which reads the variable value using the factory defined on step 3;
Deploy and run the process instance.
Expected behaviour
Value 0 is successfully assigned to the variable defined on step 2 and then successfully by the code defined on step 4.
Actual behaviour
An exception of type WrongVariableTypeException is thrown while trying to find the variable value from code, telling that it's impossible to convert value 0 to long.
Perhaps, the full stack trace is unnecessary, so I'll leave the head only:
io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException: Error reading offset: Couldn't read value of long from 0
at io.holunda.camunda.bpm.data.adapter.basic.AbstractBasicReadWriteAdapter.getOrNull(AbstractBasicReadWriteAdapter.java:51) ~[camunda-bpm-data-1.2.5.jar:na]
at io.holunda.camunda.bpm.data.adapter.basic.ReadWriteAdapterVariableScope.getOptional(ReadWriteAdapterVariableScope.java:45) ~[camunda-bpm-data-1.2.5.jar:na]
at io.holunda.camunda.bpm.data.reader.VariableScopeReader.getOptional(VariableScopeReader.java:29) ~[camunda-bpm-data-1.2.5.jar:na]
at io.holunda.camunda.bpm.data.reader.VariableReader.getOrNull(VariableReader.java:61) ~[camunda-bpm-data-1.2.5.jar:na]
at my.namespace.MyBean.myJavaDelegate$lambda-9(MyBean.kt:49) ~[main/:na]
at org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:40) ~[camunda-engine-7.16.4-ee.jar:7.16.4-ee]
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58) ~[camunda-engine-7.16.4-ee.jar:7.16.4-ee]
I assume the reason is that when a variable value is assigned by Camunda Engine, the type of its value is java.lang.Long. However Long type in kotlin is a totally different from Java's Long, and according to my observations, the corresponding Java class for it is java.base.long (at least when you retrieve it via Long::class.javaClass construct). The latter, in contrast to Java Long, is a primitive type. This causes conversion fail.
As a workaround for variables like this I had to use factories produced by CamundaBpmDataKotlin.customVariable<java.lang.Long>(...) method.
The text was updated successfully, but these errors were encountered:
In the AbstractBasicReadWriteAdapter the expected type is compared with the variable with isAssignableFrom(...) witch dose not match. The cast would succeed, but if got no pretty solution in mind so far.
Steps to reproduce
${0}
as the Variable Assignment Value expression;CamundaBpmDataKotlin.longVariable
method;Expected behaviour
Value
0
is successfully assigned to the variable defined on step 2 and then successfully by the code defined on step 4.Actual behaviour
An exception of type
WrongVariableTypeException
is thrown while trying to find the variable value from code, telling that it's impossible to convert value0
tolong
.Perhaps, the full stack trace is unnecessary, so I'll leave the head only:
I assume the reason is that when a variable value is assigned by Camunda Engine, the type of its value is
java.lang.Long
. HoweverLong
type in kotlin is a totally different from Java'sLong
, and according to my observations, the corresponding Java class for it isjava.base.long
(at least when you retrieve it viaLong::class.javaClass
construct). The latter, in contrast to JavaLong
, is a primitive type. This causes conversion fail.As a workaround for variables like this I had to use factories produced by
CamundaBpmDataKotlin.customVariable<java.lang.Long>(...)
method.The text was updated successfully, but these errors were encountered: