Details
Description
Exception NPE is thrown only when for-loop is inside def/function. Empty or more complex code in for-loop works, this bug appears only for simple code inside loop. Example:
def test() {
for(i = 0; i < 3; i++) {
// some code inside, assignment, log to console or so...
System.out.println('...');
}
}
// call function
test();
Code inside loop is executed once and then NPE is thrown, has something to do with ASTNode "null".
Fails also when there are more than one line of code inside loop, but more complex works. I am unable to find level of complexity, when begins to work. There is a sample of real script that works:
def getSQL(datefrom) { result = ""; date1 = datefrom; date2 = null; for (int i =0; i < 12; i++) { date2 = ETimeUnit.getEndDate(date1, ETimeUnit.MONTH, 1); if (!StringUtils.isEmpty(result)) { result = result + "\nUNION\n"; } result = result + getPartialSQL(i, date1, date2); date1 = date2; } result; }