Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So <code>Collection.unmodifiableList</code> is not REALLY thread-safe. This is because it create an unmodifiable view of the underlying <code>List</code>. However if the underlying <code>List</code> is modified while the view is being iterated you will get the CME. Remember that a CME does not need to be caused by a seperate thread. If I do the following I will get a CME:</p> <pre><code> for (String e : myList){ myList.remove(5); // throws CME } </code></pre> <p>The better choice is Guava's <a href="https://google.github.io/guava/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableList.html" rel="nofollow noreferrer">ImmutableList</a> which creates an immutable copy of the passed list.</p> <p>For clarification due to comments, replace the posted code with:</p> <pre><code> public List&lt;HierarchyNode&gt; getChildren() { return ImmutableList.copyOf(children); } </code></pre> <p>The <code>List</code> returned from this method is guarenteed to NEVER throw a CME.</p> <p>Update:</p> <p>If you are still trying to figure out why it is happining in your code, consider the following:</p> <ol> <li>Can the list of <code>children</code> EVER be modified (I am referring to the modifiable <code>List</code> that is passed to <code>unmodifiableList</code>)?</li> <li>Do any of the classes that call <code>getChildren</code> ever cause that class which holds the modifiable list to be invoked in a way that might update the list?</li> <li>Or do any of the classes get an instance of an <code>Iterator</code> that is used more than once?</li> </ol> <p><a href="https://google.github.io/guava/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableList.html" rel="nofollow noreferrer">ImmutableList</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload