TUSCANY-4035 - synchronize schema loading. Thanks for the patch Kaushik.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1304516 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3d3b1538aa
commit
1d6c6a11af
1 changed files with 78 additions and 68 deletions
|
@ -64,6 +64,8 @@ public class XSDModelResolver implements ModelResolver {
|
|||
private Map<String, List<XSDefinition>> map = new HashMap<String, List<XSDefinition>>();
|
||||
private XmlSchemaCollection schemaCollection;
|
||||
|
||||
private static final byte[] schemaCollectionReadLock = new byte[0];
|
||||
|
||||
public XSDModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
|
||||
this.contribution = contribution;
|
||||
this.schemaCollection = new XmlSchemaCollection();
|
||||
|
@ -143,6 +145,13 @@ public class XSDModelResolver implements ModelResolver {
|
|||
}
|
||||
|
||||
private void loadOnDemand(XSDefinition definition) throws IOException {
|
||||
|
||||
// It might be possible to use a per-XSDModelResolver-instance lock instead of the singleton lock,
|
||||
// since for a deadlock to occur it would seem to require something along the lines of A imports B imports A.
|
||||
// Since I'm not sure precisely what the restriction against circular imports is, and since I don't think it's too bad
|
||||
// to use the singleton lock (after all, loading is, in general, a one-time thing), I'll just use the singleton lock.
|
||||
synchronized (schemaCollectionReadLock) {
|
||||
|
||||
if (definition.getSchema() != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -236,6 +245,7 @@ public class XSDModelResolver implements ModelResolver {
|
|||
definition.setSchema(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSameNamespace(String ns1, String ns2) {
|
||||
if (ns1 == null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue