Defect #1673
closedProvisioning break removing from cache throw null pointer
100%
Description
During removing expired items form provisioning break cache may throw exception will null pointer:
java.lang.NullPointerException: null at java.util.LinkedList$ListItr.next(LinkedList.java:893) at java.util.Collection.removeIf(Collection.java:414) at eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems.removeOlderRecordsThan(SysProvisioningBreakItems.java:72)
This null pointer is throw in method next
Next method implementation
public E next() { checkForComodification(); if (!hasNext()) throw new NoSuchElementException(); lastReturned = next; next = next.next; nextIndex++; return lastReturned.item; }
Problem is only when two thread entry this method and both execute check hasNext() before one of them entry into line with next = next.next; This issues is very hard to simulate. And probably only way is add synchronized list or synchronized block to processor that call this cache.
Affected version: all version where exists provisioning break.
Files
Updated by Ondřej Kopr over 5 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Ondřej Kopr to Radek Tomiška
- % Done changed from 0 to 90
Synchronized list was added and also block. The issues is really hard to simulate. I created tests that create lost of thread with same start
commit: https://github.com/bcvsolutions/CzechIdMng/commit/de01670adc438367106bc37cf40cd55860905553 (branch: develop)
Please Radek could you check my changes? You will not probably able to simulate this issue. Thank you.
Updated by Ondřej Kopr over 5 years ago
Finally I can simulate same issue as on project.
The tests without synchronized list and synchronized block throw same error. So solutions for the issues is clear, add synchronized.
Updated by Radek Tomiška over 5 years ago
- Status changed from Needs feedback to Resolved
- Assignee changed from Radek Tomiška to Ondřej Kopr
- % Done changed from 90 to 100
I did code review, it's nice, thx!
Updated by Ondřej Kopr over 5 years ago
- Assignee changed from Ondřej Kopr to Radek Tomiška
Radek thank you for your feedback. After your yesterday consultation I changed threads count and interrupt thread.
There is commit: https://github.com/bcvsolutions/CzechIdMng/commit/0239f4e772a8990eb36f806501a08f8a7e1169c4 (branch: develop)
Changes are only in tests. Tests passed. Your machine including jenkins will work :D :D
Updated by Radek Tomiška over 5 years ago
- Assignee changed from Radek Tomiška to Ondřej Kopr
Thx, now it works on my environment :)