viadee / vPAV

viadee Process Application Validator

Home Page:https://www.viadee.de/java/process-application-validator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StringIndexOutOfBoundsException in BoundaryErrorChecker when BpmnError parameter is no String literal

wernz0r opened this issue · comments

Describe the bug
vPAV crashes with a StringIndexOutOfBoundsException when you don't use a string literal as parameter for "throw new BpmnError()".

To Reproduce
This works:

try{
    doSomething();
} catch(Exception e) {
    throw new BpmnError("someErrorCode");
}

This doesn't:

String myAwesomeErrorCode = "someErrorCode";
try{
    doSomething();
} catch(Exception e) {
    throw new BpmnError(myAwesomeErrorCode);
}

Expected behavior
No StringIndexOutOfBoundsException.

Desktop (please complete the following information):

  • Version 2.6.1

Thanks for your message - this checker is in experimental status currently, i.e. we are not following the error codes' path through the execution.

Also: You seem to be using an outdated version of the tool. Maybe want to give the 3.x-Version a try? It will probably not fix the above problem though - we will think about possible solutions and extensions.

Do you have some general feedback on the tool and your experience with it?

I would expect vPAV not to crash with StringIndexOutOfBoundsException. A warning that the bpmn error code could not be read would be an appropriate workaround.

Short term solution: We handle the exception more graceful so that vPAV does not abort the test.
Long term solution: Use Soot to backtrack variables in order to retrieve value

The short term solution is now implemented in the latest development branch. A warning is displayed if a variable is passed to the constructor.

I added the functionality to regocnize string objects when they are declared as final in the class where the error is thrown. Non final objects are not recognized because they can be changed and in order to retrieve the correct value we would have to backtrack the variable.
I also updated the documentation so that it is clear which options we do support. However, at the moment we do not plan to implement a more sophisticated solution with Soot because the workload would be too high for such a small improvement.

@wernz0r Does this improvement help you? Can you define your string object as final?

Thanks, thats a very good improvement!