You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Roytman, Alex" <ro...@peacetech.com> on 2001/06/02 06:22:25 UTC

Xerces 1.4 regression. Parser random validating errors when parsi ng in multiple threads

Hello,

I am having problems with Xerces 1.4 which was not present in 1.3.x
If I remember correctly there was similar problem in earlier versions under
heavy multithreaded stress which I reported and it has been fixed.

To reproduce the problem you need to parse XML with DTD and set validating
to true

- when validation is off (even if dtd is present) everything works fine. 
- when validation is on everything works fine from a single thread 
- When parsing in multiple threads with validation on parser randomly report
various validation errors.
- The same code works fine with Xerces 1.3.1

Below is my test program source

package com.peacetech.debug;

import javax.xml.parsers.*;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;

public class XmlTest extends Thread {
  private boolean stop = false;
  private String uri;
  private static SAXParserFactory parserFactory =
SAXParserFactory.newInstance();

  static {
    parserFactory.setNamespaceAware(true);
    parserFactory.setValidating(true);
  }

  public XmlTest(String uri) {
    this.uri = uri;
  }

  public void run() {
    int i = 0;
    while (!stop) {
      try {
        SAXParser parser = parserFactory.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        reader.parse(uri);
      } catch (Exception ex) {
        ex.printStackTrace();
        break;
      }
    }
  }

  public static void main(String[] args) throws Exception {
    int threadCount = 10;
    XmlTest threads[] = new XmlTest[threadCount];
    for (int i = 0; i < threads.length; i++) {
      threads[i] = new
XmlTest("file:Z:/Projects/java/peacetech/xmap/samples/ms-nwind/nwind-schema.
xml");
      threads[i].start();
    }
    Thread.currentThread().sleep(10000);
    for (int i = 0; i < threads.length; i++) {
      threads[i].stop = true;
    }
    for (int i = 0; i < threads.length; i++) {
      threads[i].join();
    }
  }
}