From f61b9984474f73d4ceed95e5df24b3c3f76df73c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 10 Feb 2016 16:22:13 +0100 Subject: [PATCH] AbstractMarshaller defensively uses DocumentBuilderFactory within synchronized block Issue: SPR-13935 --- .../org/springframework/oxm/support/AbstractMarshaller.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java index 86227a0d76..8b92f1c042 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java @@ -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 { */ 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) {