• Bug
  • Status: Closed
  • 1 Critical
  • Resolution: Fixed
  • ehcache-core
  • hsingh
  • Reporter: jbarbero
  • March 16, 2010
  • 0
  • Watchers: 1
  • January 17, 2013
  • March 17, 2010

Description

Credit to Luciano Gregorio ( luciano.gregorio (write at) renxo com )

Recently there was a change in net.sf.ehcache.event.RegisteredEventListeners in the 2.0 ehcache version.

The field RegisteredEventListeners.cacheEventListeners now use CopyOnWriteArraySet like a set implementation.

public class RegisteredEventListeners {

private final Set cacheEventListeners = new CopyOnWriteArraySet(); ... \}

The problem is that CopyOnWriteArraySet use an instance of CopyOnWriteArrayList to iterate over the listeners, and CopyOnWriteArrayList does not support the remove method, so it throws an exception java.lang.UnsupportedOperationException .

This happen when it tries to unregister an event listener.

public final boolean unregisterListener(CacheEventListener cacheEventListener) { Iterator it = cacheEventListeners.iterator(); while (it.hasNext()) { ListenerWrapper listenerWrapper = it.next(); if (listenerWrapper.getListener().equals(cacheEventListener)) { // This call throws the UnsupportedOperationException // it.remove(); return true; } } return false; \}

This happend when you call CacheManager.shutdown() for example.

Thread => http://forums.terracotta.org/forums/posts/list/3304.page

Comments

Geert Bevin 2010-03-17

FWIW, the reason why this was not caught before was because CacheEventListenerTest just logged the exception without failing the tests. I added a new test for just this now.

Himadri Singh 2010-04-07

CacheEventListenerTest is running on monkeys and not failing.