xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject svn commit: r820821 - /xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
Date Thu, 01 Oct 2009 22:15:30 GMT
Author: cezar
Date: Thu Oct  1 22:15:29 2009
New Revision: 820821

URL: http://svn.apache.org/viewvc?rev=820821&view=rev
Log:
Optimized initialization of _schemaComponent in Ref.


Modified:
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java?rev=820821&r1=820820&r2=820821&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java Thu Oct  1 22:15:29
2009
@@ -93,7 +93,7 @@
         protected Ref(SchemaTypeSystem schemaTypeSystem, String handle)
             { assert(handle != null); _schemaTypeSystem = schemaTypeSystem; _handle = handle;
}
 
-        private SchemaComponent _schemaComponent;
+        private volatile SchemaComponent _schemaComponent;
         private SchemaTypeSystem _schemaTypeSystem;
         public String _handle;
 
@@ -102,12 +102,18 @@
         public final SchemaTypeSystem getTypeSystem()
             { return _schemaTypeSystem; }
 
-        public final synchronized SchemaComponent getComponent()
+        public final SchemaComponent getComponent()
         {
             if (_schemaComponent == null && _handle != null)
             {
-                _schemaComponent = _schemaTypeSystem.resolveHandle(_handle);
-                _schemaTypeSystem = null;
+                synchronized (this)
+                {
+                    if (_schemaComponent == null && _handle != null)
+                    {
+                        _schemaComponent = _schemaTypeSystem.resolveHandle(_handle);
+                        _schemaTypeSystem = null;
+                    }
+                }
             }
 
             return _schemaComponent;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message