Skip to content

Commit 549da44

Browse files
committed
Fix
1 parent d341c21 commit 549da44

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

server/src/main/java/org/elasticsearch/action/index/IndexRequest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,18 @@ public void setStructuredSource(ESONSource.ESONObject esonSource) {
437437
public void ensureStructureSource() {
438438
if (useStructuredSource == false) {
439439
this.useStructuredSource = true;
440-
ESONSource.Builder builder = new ESONSource.Builder((int) (source.length() * 0.70));
441-
try {
442-
XContentParser parser = XContentHelper.createParser(XContentParserConfiguration.EMPTY, source, contentType);
443-
structuredSource = builder.parse(parser);
444-
} catch (IOException e) {
445-
throw new UncheckedIOException(e);
446-
}
440+
createdStructuredSource();
447441
}
442+
}
448443

444+
private void createdStructuredSource() {
445+
ESONSource.Builder builder = new ESONSource.Builder((int) (source.length() * 0.70));
446+
try {
447+
XContentParser parser = XContentHelper.createParser(XContentParserConfiguration.EMPTY, source, contentType);
448+
structuredSource = builder.parse(parser);
449+
} catch (IOException e) {
450+
throw new UncheckedIOException(e);
451+
}
449452
}
450453

451454
public boolean isStructuredSource() {
@@ -582,7 +585,7 @@ public IndexRequest source(BytesReference source, XContentType xContentType) {
582585
this.source = Objects.requireNonNull(source);
583586
this.contentType = Objects.requireNonNull(xContentType);
584587
if (useStructuredSource) {
585-
ensureStructureSource();
588+
createdStructuredSource();
586589
}
587590
return this;
588591
}

server/src/main/java/org/elasticsearch/ingest/ESONXContentParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.OutputStream;
2323
import java.nio.CharBuffer;
2424
import java.util.ArrayDeque;
25+
import java.util.Base64;
2526
import java.util.Deque;
2627
import java.util.List;
2728

@@ -493,8 +494,10 @@ public byte[] binaryValue() throws IOException {
493494
getCurrentValue();
494495
if (currentValue instanceof byte[] bytes) {
495496
return bytes;
497+
} else {
498+
// TODO: Research correct approach
499+
return Base64.getDecoder().decode(currentValue.toString());
496500
}
497-
throw new IllegalStateException("Current token is not a binary value");
498501
}
499502

500503
@Override

0 commit comments

Comments
 (0)