Author: vgritsenko Date: Sun Nov 9 13:49:50 2008 New Revision: 712562 URL: http://svn.apache.org/viewvc?rev=712562&view=rev Log: synchronize streamFromXML() method
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/SymbolTable.java Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/SymbolTable.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/SymbolTable.java?rev=712562&r1=712561&r2=712562&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/xml/SymbolTable.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/xml/SymbolTable.java Sun Nov 9 13:49:50 2008 @@ -44,14 +44,14 @@ static final String NSURI = "nsuri"; static final String ID = "id"; - private transient boolean dirty; - private transient long lastModified = System.currentTimeMillis(); - private short maxSymbol = -1; private final Map symbols = new HashMap(); // String to SymbolInfo private final Map names = new HashMap(); // Short to SymbolInfo private boolean readOnly; + private transient boolean dirty; + private transient long lastModified = System.currentTimeMillis(); + public static final class SymbolInfo implements Serializable { private final String namespaceURI; @@ -319,35 +319,37 @@ } public final void streamFromXML(Element element) throws DOMException { - symbols.clear(); - names.clear(); - maxSymbol = -1; - - NodeList list = element.getElementsByTagName(SYMBOL); - int size = list.getLength(); - for (int i = 0; i < size; i++) { - Element elem = (Element) list.item(i); - - String qname = elem.getAttribute(NAME); - String namespaceURI = elem.getAttribute(NSURI); - if (namespaceURI != null && namespaceURI.length() == 0) { - namespaceURI = null; - } + synchronized (symbols) { + maxSymbol = -1; + symbols.clear(); + names.clear(); + + NodeList list = element.getElementsByTagName(SYMBOL); + int size = list.getLength(); + for (int i = 0; i < size; i++) { + Element elem = (Element) list.item(i); + + String qname = elem.getAttribute(NAME); + String namespaceURI = elem.getAttribute(NSURI); + if (namespaceURI != null && namespaceURI.length() == 0) { + namespaceURI = null; + } - short id = Short.parseShort(elem.getAttribute(ID)); - if (id > maxSymbol) { - maxSymbol = id; - } + short id = Short.parseShort(elem.getAttribute(ID)); + if (id > maxSymbol) { + maxSymbol = id; + } - SymbolInfo info = new SymbolInfo(qname, namespaceURI, id); - if (namespaceURI != null) { - String lookupName = getLookupName(qname, namespaceURI); - symbols.put(lookupName, info); - } else { - symbols.put(qname, info); - } + SymbolInfo info = new SymbolInfo(qname, namespaceURI, id); + if (namespaceURI != null) { + String lookupName = getLookupName(qname, namespaceURI); + symbols.put(lookupName, info); + } else { + symbols.put(qname, info); + } - names.put(new Short(id), info); + names.put(new Short(id), info); + } } }