diff options
author | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-29 01:09:54 +0000 |
---|---|---|
committer | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-29 01:09:54 +0000 |
commit | 169777e33763d7a38fdaad4449d168c12832a623 (patch) | |
tree | a0000de5de8d00b3ee4118fce676429505c39b6b /branches | |
parent | b1a12e7d24e358f7c7d3bdc160ab023f13b37bd3 (diff) |
Fix for TUSCANY-3065. Thanks Greg.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@779808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches')
-rw-r--r-- | branches/sca-java-1.x/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/branches/sca-java-1.x/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java b/branches/sca-java-1.x/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java index d5cd68cd70..27c46cdb21 100644 --- a/branches/sca-java-1.x/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java +++ b/branches/sca-java-1.x/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java @@ -49,7 +49,6 @@ import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper; public class JAXBDataSource extends OMDataSourceExtBase { private JAXBContext context; private Object element; - private Marshaller marshaller; public JAXBDataSource(Object element, JAXBContext context) { this.element = element; @@ -57,11 +56,7 @@ public class JAXBDataSource extends OMDataSourceExtBase { } private Marshaller getMarshaller() throws JAXBException { - if (marshaller == null) { - // For thread safety, not sure we can cache the marshaller - marshaller = JAXBContextHelper.getMarshaller(context); - } - return marshaller; + return JAXBContextHelper.getMarshaller(context); } private void releaseMarshaller(Marshaller marshaller) { @@ -103,8 +98,9 @@ public class JAXBDataSource extends OMDataSourceExtBase { // marshaller.setProperty(Marshaller.JAXB_ENCODING, format.getCharSetEncoding()); AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { + Marshaller marshaller = null; try { - Marshaller marshaller = getMarshaller(); + marshaller = getMarshaller(); // Marshalling directly to the output stream is faster than marshalling through the // XMLStreamWriter. Take advantage of this optimization if there is an output stream. OutputStream os = getOutputStream(xmlWriter); @@ -129,8 +125,9 @@ public class JAXBDataSource extends OMDataSourceExtBase { // marshaller.setProperty(Marshaller.JAXB_ENCODING, format.getCharSetEncoding()); AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { + Marshaller marshaller = null; try { - Marshaller marshaller = getMarshaller(); + marshaller = getMarshaller(); marshaller.marshal(element, output); } finally { releaseMarshaller(marshaller); @@ -147,8 +144,9 @@ public class JAXBDataSource extends OMDataSourceExtBase { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { + Marshaller marshaller = null; try { - Marshaller marshaller = getMarshaller(); + marshaller = getMarshaller(); marshaller.marshal(element, writer); } finally { releaseMarshaller(marshaller); @@ -176,9 +174,10 @@ public class JAXBDataSource extends OMDataSourceExtBase { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<byte[]>() { public byte[] run() throws JAXBException, XMLStreamException, UnsupportedEncodingException { + Marshaller marshaller = null; try { StringWriter sw = new StringWriter(); - Marshaller marshaller = getMarshaller(); + marshaller = getMarshaller(); marshaller.marshal(element, sw); return sw.toString().getBytes(encoding); } finally { |