With vCard4J version 1.1.3, the DomParser class is not
thread safe. This wouldn't be so much of an issue,
except that the process of instantiating a DomParser is
pretty heavy: you have to read in and parse the DTD for
the various vCard specs each time. This means that in
high-performance situations (such as, for example, on a
web application server) where multiple simultaneous
requests might be coming in, you'll have to create and
destroy DomParsers all the time.
A couple of solutions spring to mind:
1) make the parse method thread safe. This might be
tricky, especially if the DomParser contains a SAX
parser and is using that during the parse process.
2) Create a DomParserFactory that reads the config
files when it gets instantiated, and then provides a
getDomParser() method that builds a new DomParser from
the already read-in files. This is still kind of heavy,
but at least we don't have to hit the filesystem every
time we want a DomParser.
Log in to post a comment.