Browse Source

AbstractMarshaller defensively uses DocumentBuilderFactory within synchronized block

Issue: SPR-13935
(cherry picked from commit f61b998)
pull/966/head
Juergen Hoeller 10 years ago
parent
commit
5047e90625
  1. 5
      spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java

5
spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -130,12 +130,13 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller { @@ -130,12 +130,13 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
*/
protected Document buildDocument() {
try {
DocumentBuilder documentBuilder;
synchronized (this.documentBuilderFactoryMonitor) {
if (this.documentBuilderFactory == null) {
this.documentBuilderFactory = createDocumentBuilderFactory();
}
documentBuilder = createDocumentBuilder(this.documentBuilderFactory);
}
DocumentBuilder documentBuilder = createDocumentBuilder(this.documentBuilderFactory);
return documentBuilder.newDocument();
}
catch (ParserConfigurationException ex) {

Loading…
Cancel
Save