Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-268

Fix synchronization issues in InMemoryDataTree

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Won't Do
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 1570

    Description

      There's a couple issues in InMemoryDataTree wrt to synchronization:

      1) There's redundant synchronization in the setSchemaContext, validate, prepare and commit methods, ie the methods are both synchronized and they use the read/write lock. The synchronized keyword should be removed (it's not good practice anyway to synchronize methods). I suspect the read/write lock was added afterwards and the person forgot to remove synchronized.

      2) The validate method accesses the 'rootNode' member completely unsynchronized. This is unsafe - all accesses to 'rootNode' must be synchronized wrt to one another. Since validate doesn't modify the 'rootNode' it can acquire the read lock. It passes 'rootNode' to another class and I don't think we need to hold the lock across that call so we should be able to do:

      TreeNode localRootNode;
      rwLock.readLock().lock();
      try

      { localRootNode = rootNode; }

      finally

      { rwLock.readLock().unlock(); }

      m.getStrategy().checkApplicable(..., Optional.<TreeNode>of(localRootNode));

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpantelis Tom Pantelis
            tpantelis Tom Pantelis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: