AnsweredAssumed Answered

DbSqlSession.getUpdatedObjects() and byte arrays

Question asked by philipp91 on Jan 7, 2013
Latest reply on Mar 27, 2013 by frederikheremans1
Hi,

we have an Activiti-based application that loads a large number of tasks and uses getVariablesLocal() to retrieve additional information. However, when used with a larger number of tasks, it crashes due to an ActivitiOptimisticLockingException, although nothing is supposed to be saved to the database, only loading should happen.

I debugged the application and found that getVariablesLocal() causes these updates. The CommandContextInterceptor closes the context, which causes the DbSqlSession to be flushed and the DbSqlSession decides to write all ByteArrayEntities back to the database because of a bug in getUpdatedObjects():
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSession.java#L564
if (!persistentObject.getPersistentState().equals(originalState)) {
Both persistentObject.getPersistentState() and originalStates will be a byte[] in this case, but boxed by Java, so the .equals()-method does not work as expected.

Try this in a Unit-Test:
assertEquals(new byte[] {1}, new byte[] {1})
and it will fail.

Regards,
Philipp

Outcomes