Skip to content

Commit

Permalink
Add failing test for #130 (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 24, 2020
1 parent 2a07652 commit f0e05b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,18 @@ public JsonToken nextToken() throws IOException
protected JsonToken _decodeScalar(ScalarEvent scalar) throws IOException
{
String value = scalar.getValue();

_textValue = value;
_cleanedTextValue = null;

// [dataformats-text#130]: uncomment for 2.13 either as-is, or
// behind a new feature
/*
if (value.isEmpty()) {
return JsonToken.VALUE_STRING;
}
*/

// we may get an explicit tag, if so, use for corroborating...
String typeTag = scalar.getTag();
final int len = value.length();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fasterxml.jackson.dataformat.yaml.failing;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;

// [dataformats-text#130]: Easy enough to fix, if we choose to,
// but due to timing cannot include in 2.12 (too close to release
// after RCs)
//
// Fix to be done by ignoring snakeyaml's implicit type for case of
// empty String (in `YAMLParser.
public class NullFromEmptyString130Test extends ModuleTestBase
{
static class Value130 {
public String value;

public void setValue(String str) {
value = str;
}
}

private final ObjectMapper MAPPER = newObjectMapper();

// [dataformats-text#130]
public void testEmptyValueToNull130() throws Exception
{
Value130 v = MAPPER.readerFor(Value130.class)
.readValue("value: \n");
assertEquals("", v.value);
}
}

0 comments on commit f0e05b8

Please sign in to comment.