Project

General

Profile

Actions

Defect #1673

closed

Provisioning break removing from cache throw null pointer

Added by Ondřej Kopr almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Ondřej Kopr
Category:
Provisioning
Target version:
Start date:
05/21/2019
Due date:
% Done:

100%

Estimated time:
Affected versions:
Owner:

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

err.png (219 KB) err.png Ondřej Kopr, 05/23/2019 08:09 AM
Actions #1

Updated by Ondřej Kopr almost 5 years ago

  • Status changed from New to In Progress
Actions #2

Updated by Ondřej Kopr almost 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.

Actions #3

Updated by Ondřej Kopr almost 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.

Actions #4

Updated by Radek Tomiška almost 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!

Actions #5

Updated by Ondřej Kopr almost 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

Actions #6

Updated by Radek Tomiška almost 5 years ago

  • Assignee changed from Radek Tomiška to Ondřej Kopr

Thx, now it works on my environment :)

Actions #7

Updated by Ondřej Kopr almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF