Skip to content

Commit

Permalink
Remove YAML Base64 serialization hack (MID-4974)
Browse files Browse the repository at this point in the history
The original issue 90 in jackson was fixed, so we removed
our hacked workaround.
  • Loading branch information
mederly committed Apr 2, 2020
1 parent 7e95c81 commit a09ace3
Showing 1 changed file with 0 additions and 37 deletions.
Expand Up @@ -69,41 +69,4 @@ public void newDocument() throws IOException {
_emitter.emit(new DocumentEndEvent(null, null, false));
_emitter.emit(new DocumentStartEvent(null, null, true, version, Collections.emptyMap()));
}

/*
* UGLY HACK - working around YAML serialization problem
* (https://github.com/FasterXML/jackson-dataformats-text/issues/90)
*
* TODO - after YAML problem is fixed, remove this code block (MID-4974)
* TODO - if upgrading YAML library before that, make sure everything works (because this code is almost literally copied from YAMLGenerator class)
*/

@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException
{
if (data == null) {
writeNull();
return;
}
_verifyValueWrite("write Binary value");
if (offset > 0 || (offset+len) != data.length) {
data = Arrays.copyOfRange(data, offset, offset+len);
}
writeScalarBinaryPatched(b64variant, data);
}

private final static ImplicitTuple EXPLICIT_TAGS = new ImplicitTuple(false, false);
private final static Character STYLE_LITERAL = '|';
private final static Character STYLE_BASE64 = STYLE_LITERAL;

private void writeScalarBinaryPatched(Base64Variant b64variant, byte[] data) throws IOException
{
String encoded = b64variant.encode(data);
_emitter.emit(new ScalarEvent(null, TAG_BINARY, EXPLICIT_TAGS, encoded,
null, null, STYLE_BASE64));
}

/*
* END OF UGLY HACK
*/
}

0 comments on commit a09ace3

Please sign in to comment.