Author: doogie
Date: Wed Apr 18 23:48:33 2012 New Revision: 1327734 URL: http://svn.apache.org/viewvc?rev=1327734&view=rev Log: FEATURE: Remove synchronization on UtilCache access in ModelFieldTypeReader. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java?rev=1327734&r1=1327733&r2=1327734&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java Wed Apr 18 23:48:33 2012 @@ -73,27 +73,26 @@ public class ModelFieldTypeReader implem } String tempModelName = datasourceInfo.fieldTypeName; ModelFieldTypeReader reader = readers.get(tempModelName); - if (reader == null) { - synchronized (readers) { - FieldTypeInfo fieldTypeInfo = EntityConfigUtil.getFieldTypeInfo(tempModelName); - if (fieldTypeInfo == null) { - throw new IllegalArgumentException("Could not find a field-type definition with name \"" + tempModelName + "\""); - } - ResourceHandler fieldTypeResourceHandler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, fieldTypeInfo.resourceElement); - UtilTimer utilTimer = new UtilTimer(); - utilTimer.timerString("[ModelFieldTypeReader.getModelFieldTypeReader] Reading field types from " + fieldTypeResourceHandler.getLocation()); - Document document = null; - try { - document = fieldTypeResourceHandler.getDocument(); - } catch (GenericConfigException e) { - Debug.logError(e, module); - throw new IllegalStateException("Error loading field type file " + fieldTypeResourceHandler.getLocation()); - } - Map<String, ModelFieldType> fieldTypeMap = createFieldTypeCache(document.getDocumentElement(), fieldTypeResourceHandler.getLocation()); - reader = new ModelFieldTypeReader(fieldTypeMap); - readers.put(tempModelName, reader); - utilTimer.timerString("[ModelFieldTypeReader.getModelFieldTypeReader] Read " + fieldTypeMap.size() + " field types"); + while (reader == null) { + FieldTypeInfo fieldTypeInfo = EntityConfigUtil.getFieldTypeInfo(tempModelName); + if (fieldTypeInfo == null) { + throw new IllegalArgumentException("Could not find a field-type definition with name \"" + tempModelName + "\""); } + ResourceHandler fieldTypeResourceHandler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, fieldTypeInfo.resourceElement); + UtilTimer utilTimer = new UtilTimer(); + utilTimer.timerString("[ModelFieldTypeReader.getModelFieldTypeReader] Reading field types from " + fieldTypeResourceHandler.getLocation()); + Document document = null; + try { + document = fieldTypeResourceHandler.getDocument(); + } catch (GenericConfigException e) { + Debug.logError(e, module); + throw new IllegalStateException("Error loading field type file " + fieldTypeResourceHandler.getLocation()); + } + Map<String, ModelFieldType> fieldTypeMap = createFieldTypeCache(document.getDocumentElement(), fieldTypeResourceHandler.getLocation()); + reader = new ModelFieldTypeReader(fieldTypeMap); + readers.putIfAbsent(tempModelName, reader); + utilTimer.timerString("[ModelFieldTypeReader.getModelFieldTypeReader] Read " + fieldTypeMap.size() + " field types"); + reader = readers.get(tempModelName); } return reader; } |
Free forum by Nabble | Edit this page |