@@ -307,13 +307,12 @@ public void add(String key, String value) {
307307 }
308308 }
309309
310- private DocumentCollections collections ;
311- private DocumentPermissions permissions ;
312- private DocumentProperties properties ;
313- private int quality = 0 ;
310+ private DocumentCollections collections ;
311+ private DocumentPermissions permissions ;
312+ private DocumentProperties properties ;
313+ private int quality = 0 ;
314314 private DocumentMetadataValues metadataValues ;
315- private boolean qualityModified = false ;
316- private ValueSerializer valueSerializer ;
315+ private boolean qualityModified = false ;
317316
318317 /**
319318 * Zero-argument constructor.
@@ -772,8 +771,6 @@ private void sendMetadataImpl(OutputStream out) {
772771 try {
773772 XMLOutputFactory factory = XmlFactories .getOutputFactory ();
774773
775- valueSerializer = null ;
776-
777774 XMLStreamWriter serializer = factory .createXMLStreamWriter (out , "UTF-8" );
778775
779776 serializer .writeStartDocument ("utf-8" , "1.0" );
@@ -803,8 +800,6 @@ private void sendMetadataImpl(OutputStream out) {
803800 throw new MarkLogicIOException ("Failed to serialize metadata" , e );
804801 } catch (TransformerException e ) {
805802 throw new MarkLogicIOException ("Failed to serialize metadata" , e );
806- } finally {
807- valueSerializer = null ;
808803 }
809804 }
810805
@@ -859,6 +854,9 @@ private void sendPermissionsImpl(XMLStreamWriter serializer) throws XMLStreamExc
859854 }
860855 private void sendPropertiesImpl (final XMLStreamWriter serializer ) throws XMLStreamException , TransformerFactoryConfigurationError , TransformerException {
861856 if ( getProperties () == null || getProperties ().size () == 0 ) return ;
857+
858+ ValueSerializer valueSerializer = null ;
859+
862860 serializer .writeStartElement ("prop" , "properties" , PROPERTY_API_NS );
863861
864862 for (Map .Entry <QName , Object > property : getProperties ().entrySet ()) {
@@ -894,6 +892,8 @@ private void sendPropertiesImpl(final XMLStreamWriter serializer) throws XMLStre
894892 }
895893
896894 serializer .writeEndElement ();
895+
896+ valueSerializer = null ;
897897 }
898898 private void sendQualityImpl (XMLStreamWriter serializer ) throws XMLStreamException {
899899 if ( qualityModified == false ) return ;
0 commit comments