/** * Notifies all <code>ChatRoomClosingListener</code> that this ChatRoom is closing. */ private void fireClosingListeners() { for ( final ChatRoomClosingListener listener : new ArrayList<>( closingListeners ) ) // Listener can call #removeClosingListener. Prevent ConcurrentModificationException by using a clone. { try { listener.closing(); } catch ( Exception e ) { Log.error( "A ChatRoomClosingListener (" + listener + ") threw an exception while processing a 'closing' event.", e ); } } closingListeners.clear(); }