Bug 1965 - Parser random validating errors when parsing in multiple threads
Summary: Parser random validating errors when parsing in multiple threads
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: SAX (show other bugs)
Version: 1.4
Hardware: PC All
: P3 major
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-06-01 21:14 UTC by Alex Roytman
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Roytman 2001-06-01 21:14:24 UTC
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.

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();
    }
  }
}