-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #2136 - NPE in ExpressionOperator.printCollection #2137
Conversation
…ator.printCollection since 2.7.11 The bug is described in detail in eclipse-ee4j#2136 We are looping over an array which is located in the instance field which can be set to `null` while lopping which is causing NPE. To fix it we are caching the value of `argumentIndices` by looping over an iterator of the array.
If this PR will be approved, the same thing should be done on the 3.0.x branch |
I'm asking itself how this change helps |
@rfelcman yeah, this is very hard to spot. Example: class Sample {
private int[] fields;
public void willWork() {
fields = new int[] {1,2,3};
for (int n : this.fields) {
System.out.println(n);
this.fields = null;
}
}
public void willFail() {
fields = new int[] {1,2,3};
for (int i = 0; i < this.fields.length; i++) {
int n = this.fields[i];
System.out.println(n);
this.fields = null;
}
}
public static void main(String[] args) {
System.out.println("Will work:");
new Sample().willWork();
System.out.println("Will fail:");
new Sample().willFail();
}
} |
As others mentioned NPE under stress it looks like concurrency issue not simple NPE. |
For our project the issue does not happen under stress. It just happens sometimes. My first take on the issue was also concurrency, but we also have logs where the issue happens surely when there is only one thread. Also the best indication for the issue is that it was introduced in 2.7.11 where the line Every reporter of the problem agrees that the bug was introduced in 2.7.11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just please update copyright year in the class header
…e-ee4j#2141) Fixes eclipse-ee4j#2136 Backport from eclipse-ee4j#2137 Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
The bug is described in detail in #2136
We are looping over an array which is located in the instance field which can be set to
null
while lopping which is causing NPE. To fix it we are caching the value ofargumentIndices
by looping over an iterator of the array.