/** * @see java.util.Map#putAll(java.util.Map) */ public void _putAll(Map<? extends K,? extends V> map) { if(map == null) return; // Calling the method below seems okay, but would result in ... deadlock ! // The reason is that Map.putAll() calls put(), which we override, which results in // lock contention for the map. // ---> super.putAll(m); <--- CULPRIT !!!@#$%$ // That said let's do it the stupid way: for(Map.Entry<? extends K,? extends V> entry:map.entrySet()) { this.map.put(entry.getKey(), entry.getValue()); } if(!map.isEmpty()) { for(Notification notif:notifs) notif.contentsSet(map); } }
/** * @see java.util.Map#putAll(java.util.Map) */ public void _putAll(Map<? extends K,? extends V> map) { if(map == null) return; // Calling the method below seems okay, but would result in ... deadlock ! // The reason is that Map.putAll() calls put(), which we override, which results in // lock contention for the map. // ---> super.putAll(m); <--- CULPRIT !!!@#$%$ // That said let's do it the stupid way: for(Map.Entry<? extends K,? extends V> entry:map.entrySet()) { this.map.put(entry.getKey(), entry.getValue()); } if(!map.isEmpty()) { for(Notification notif:notifs) notif.contentsSet(map); } }
/** * @see java.util.Map#putAll(java.util.Map) */ public void _putAll(Map<? extends K, ? extends V> map) { if(map == null) return; // Calling the method below seems okay, but would result in ... deadlock ! // The reason is that Map.putAll() calls put(), which we override, which results in // lock contention for the map. // ---> super.putAll(m); <--- CULPRIT !!!@#$%$ // That said let's do it the stupid way: for(Map.Entry<? extends K,? extends V> entry: map.entrySet()) { super.put(entry.getKey(), entry.getValue()); } if(persistent) { try { persistence_mgr.saveAll(map); } catch(CannotPersistException persist_ex) { if(log.isErrorEnabled()) log.error("failed persisting contents: " + persist_ex); } catch(Throwable t) { if(log.isErrorEnabled()) log.error("failed persisting contents: " + t); } } for(int i=0; i < notifs.size(); i++) notifs.elementAt(i).contentsSet(map); }