In org.activiti.engine.impl.AbstractNativeQuery, lines 130-134 are:
If the variable maxResults is equal to the maximum integer value, then the variable lastRow is set but then immediately overwritten by the next line of code.
Attached is a java test program, MaxValue.java, that shows the issue and the subsequent issues with possible integer overflows.
The suggested change is:
There is patch file attachment that implements this change.
This issue was introduced in commit ef36793d911cc903d618a876d1b81604305b3f15 on 16May2013.