From: Mailing l. f. S. c. m. <jtc...@li...> - 2008-03-20 06:33:55
|
Revision: 3037 http://jtcfrost.svn.sourceforge.net/jtcfrost/?rev=3037&view=rev Author: bback Date: 2008-03-19 23:33:48 -0700 (Wed, 19 Mar 2008) Log Message: ----------- - fix for possible concurrent modification Modified Paths: -------------- trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java Modified: trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java =================================================================== --- trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java 2008-03-15 15:10:41 UTC (rev 3036) +++ trunk/frost-wot/source/frost/storage/perst/identities/IdentitiesStorage.java 2008-03-20 06:33:48 UTC (rev 3037) @@ -119,25 +119,37 @@ public Hashtable<String,Identity> loadIdentities() { final Hashtable<String,Identity> result = new Hashtable<String,Identity>(); - beginCooperativeThreadTransaction(); + + final boolean migrateIdStorage; + if( storageRoot.getMigrationLevel() < IdentitiesStorageRoot.MIGRATION_LEVEL_1 ) { + migrateIdStorage = true; + // read and maybe remove ids + beginExclusiveThreadTransaction(); + } else { + migrateIdStorage = false; + // only read ids + beginCooperativeThreadTransaction(); + } + try { for( final Identity id : storageRoot.getIdentities() ) { if( id == null ) { logger.severe("Retrieved a null id !!! Please repair identities.dbs."); } else { - if( storageRoot.getMigrationLevel() < IdentitiesStorageRoot.MIGRATION_LEVEL_1 ) { - // one-time migration, remove all ids that have a '_' instead of an '@' - if( !Core.getIdentities().isIdentityValid(id) ) { - removeIdentity(id); - logger.severe("Dropped an invalid identity: "+id.getUniqueName()); - continue; - } + // one-time migration, remove all ids that have a '_' instead of an '@' + if( migrateIdStorage && !Core.getIdentities().isIdentityValid(id) ) { + removeIdentity(id); + logger.severe("Dropped an invalid identity: "+id.getUniqueName()); + } else { + result.put(id.getUniqueName(), id); } - result.put(id.getUniqueName(), id); } } } finally { - storageRoot.setMigrationLevel(IdentitiesStorageRoot.MIGRATION_LEVEL_1); + if( migrateIdStorage ) { + // migration finished + storageRoot.setMigrationLevel(IdentitiesStorageRoot.MIGRATION_LEVEL_1); + } endThreadTransaction(); } return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |