nizhikov commented on a change in pull request #7563: IGNITE-12749 Fixed unsupported operation exception on node stop if collisionspi not null URL: https://github.com/apache/ignite/pull/7563#discussion_r397751526
########## File path: modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java ########## @@ -1536,10 +1536,49 @@ public V replacex(K key, V oldVal, V newVal) { } /** - * Removes all of the mappings from this map. + * Removes all of the mappings from this map. Performs global locking of the table. */ @Override public void clear() { - throw new UnsupportedOperationException(); + + try { + lockWriteLocks(); + replaceOldSegments(); + + } finally { + unlockWriteLocks(); + } + } + + /** + * Replaces all segments with the new ones and increments modification count for the table. + */ + private void replaceOldSegments() { + for (int i = 0; i < segments.length; i++) { + segments[i] = new Segment<>(DFLT_INIT_CAP, DFLT_LOAD_FACTOR); + } + + modCnt.increment(); + } + + /** + * Tries to lock all segments in order which they appear to be in an underlying array. + */ + @SuppressWarnings("LockAcquiredButNotSafelyReleased") + private void lockWriteLocks() { + for (Segment<K, V> segment : segments) { + segment.writeLock().lock(); Review comment: What is thread will be interrupted in the middle of this loop? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services