mrglavas 2005/08/09 10:52:33 Modified: java/src/org/apache/xerces/impl/xpath/regex RangeToken.java Log: Attempting to fix JIRA Issues #1054 & #1076: http://issues.apache.org/jira/browse/XERCESJ-1054 http://issues.apache.org/jira/browse/XERCESJ-1076 The first time match() is called on a RangeToken, a map is created for fast lookups. There was a race condition which made it possible for the map to be refill while another thread was reading from it. Though I've never been able to reproduce either JIRA issue, it looks like this could have been the problem. Now we assign the map only once it's been filled. Revision Changes Path 1.8 +16 -10 xml-xerces/java/src/org/apache/xerces/impl/xpath/regex/RangeToken.java Index: RangeToken.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xpath/regex/RangeToken.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- RangeToken.java 22 Mar 2005 03:23:06 -0000 1.7 +++ RangeToken.java 9 Aug 2005 17:52:33 -0000 1.8 @@ -510,24 +510,30 @@ private static final int MAPSIZE = 256; private void createMap() { int asize = MAPSIZE/32; // 32 is the number of bits in `int'. - this.map = new int[asize]; - this.nonMapIndex = this.ranges.length; - for (int i = 0; i < asize; i ++) this.map[i] = 0; - for (int i = 0; i < this.ranges.length; i += 2) { + int [] map = new int[asize]; + int nonMapIndex = this.ranges.length; + for (int i = 0; i < asize; ++i) { + map[i] = 0; + } + for (int i = 0; i < this.ranges.length; i += 2) { int s = this.ranges[i]; int e = this.ranges[i+1]; if (s < MAPSIZE) { - for (int j = s; j <= e && j < MAPSIZE; j ++) - this.map[j/32] |= 1<<(j&0x1f); // s&0x1f : 0-31 - } else { - this.nonMapIndex = i; + for (int j = s; j <= e && j < MAPSIZE; j++) { + map[j/32] |= 1<<(j&0x1f); // s&0x1f : 0-31 + } + } + else { + nonMapIndex = i; break; } if (e >= MAPSIZE) { - this.nonMapIndex = i; + nonMapIndex = i; break; } } + this.map = map; + this.nonMapIndex = nonMapIndex; //for (int i = 0; i < asize; i ++) System.err.println("Map: "+Integer.toString(this.map[i], 16)); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
