Skip to content

Commit d56a832

Browse files
author
ehennum
committed
value serializer in stack instead of field #646
1 parent d9e7315 commit d56a832

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/io/BytesHandle.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ public BytesHandle(byte[] content) {
9999
this();
100100
set(content);
101101
}
102+
/**
103+
* Initializes the handle from the byte content of another handle
104+
* @param content the other handle
105+
*/
106+
public BytesHandle(BufferableHandle content) {
107+
this((content == null) ? null : content.toBuffer());
108+
}
102109

103110
/**
104111
* Returns the byte array for the handle content.

marklogic-client-api/src/main/java/com/marklogic/client/io/DocumentMetadataHandle.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)