Skip to content

Commit 794d9e1

Browse files
author
ehennum
committed
fixup on streaming handle for Jackson parser #1250
1 parent 944800f commit 794d9e1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/JacksonBaseHandle.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public void fromBuffer(byte[] buffer) {
6767
receiveContent(new ByteArrayInputStream(buffer));
6868
}
6969
public byte[] toBuffer() {
70-
return contentToBytes(get());
70+
byte[] b = contentToBytes(get());
71+
if (!isResendable())
72+
fromBuffer(b);
73+
return b;
7174
}
7275
public T bytesToContent(byte[] buffer) {
7376
return toContent(new ByteArrayInputStream(buffer));

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,12 @@ protected OutputStreamSender sendContent() {
183183
}
184184
@Override
185185
protected OutputStreamSender sendContent(JsonParser parser) {
186-
if (parser == null) return null;
187-
return new OutputStreamSenderImpl(getMapper(), parser);
186+
try {
187+
if (parser == null || parser.nextToken() == null) return null;
188+
return new OutputStreamSenderImpl(getMapper(), parser);
189+
} catch (IOException e) {
190+
throw new MarkLogicIOException("Failed to parse content", e);
191+
}
188192
}
189193

190194
@Override

0 commit comments

Comments
 (0)