AbstractMarshaller defensively uses DocumentBuilderFactory within synchronized block

Issue: SPR-13935
This commit is contained in:
Juergen Hoeller 2016-02-10 16:22:13 +01:00
parent c788a8a260
commit f61b998447
1 changed files with 3 additions and 2 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 {
*/ */
protected Document buildDocument() { protected Document buildDocument() {
try { try {
DocumentBuilder documentBuilder;
synchronized (this.documentBuilderFactoryMonitor) { synchronized (this.documentBuilderFactoryMonitor) {
if (this.documentBuilderFactory == null) { if (this.documentBuilderFactory == null) {
this.documentBuilderFactory = createDocumentBuilderFactory(); this.documentBuilderFactory = createDocumentBuilderFactory();
} }
documentBuilder = createDocumentBuilder(this.documentBuilderFactory);
} }
DocumentBuilder documentBuilder = createDocumentBuilder(this.documentBuilderFactory);
return documentBuilder.newDocument(); return documentBuilder.newDocument();
} }
catch (ParserConfigurationException ex) { catch (ParserConfigurationException ex) {