Avoid making the Iterator in enumerateSites throw a
ConcurrentModificationException when we add a new site. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1304 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: JDBCTableSiteIdentifier.java,v 1.10 2003/11/13 17:28:58 mdb Exp $
|
// $Id: JDBCTableSiteIdentifier.java,v 1.11 2003/11/13 18:36:52 ray Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -144,9 +144,14 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier
|
|||||||
site.siteString = siteString;
|
site.siteString = siteString;
|
||||||
_repo.insertNewSite(site);
|
_repo.insertNewSite(site);
|
||||||
|
|
||||||
// add it to our two mapping tables
|
// add it to our two mapping tables,
|
||||||
_sitesById.put(site.siteId, site);
|
// avoiding causing enumerateSites() to choke
|
||||||
_sitesByString.put(site.siteString, site);
|
HashMap newStrings = (HashMap) _sitesByString.clone();
|
||||||
|
HashIntMap newIds = (HashIntMap) _sitesById.clone();
|
||||||
|
newIds.put(site.siteId, site);
|
||||||
|
newStrings.put(site.siteString, site);
|
||||||
|
_sitesByString = newStrings;
|
||||||
|
_sitesById = newIds;
|
||||||
|
|
||||||
return site;
|
return site;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user