Skip to content

Commit

Permalink
Update release notes wrt #146; minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 25, 2020
1 parent 2cf9d0a commit e3c6b4b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 44 deletions.
8 changes: 8 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ Jason van Zyl (jvanzyl@github)
Jochen Schalanda (joschi@github)
* Reported #187: Update to SnakeYAML to 1.26 (from 1.24) to address CVE-2017-18640
(2.10.4)

Sergey Medelyan (smedelyan@github)
* Reported #146: Jackson can't handle underscores in numbers
(2.10.5)

Conor Ward (conor-ward@github)
* Contributed fix for #146: Jackson can't handle underscores in numbers
(2.10.5)
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Modules:
=== Releases ===
------------------------------------------------------------------------

2.10.5 (not yet released)

#146: Jackson can't handle underscores in numbers
(reported by Sergey M; fix contributed by Conor W)
2.10.4 (03-May-2020)
#179 (properties): `JavaPropsMapper` doesn't close the .properties file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ public String getTypeId() throws IOException
*/

/**
* Helper method used to clean up YAML floating-point value so it can be parsed
* Helper method used to clean up YAML integer value so it can be parsed
* using standard JDK classes.
* Currently this just means stripping out optional underscores.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,37 @@
@SuppressWarnings("resource")
public class ParserAutoCloseTest extends ModuleTestBase
{
private final ObjectMapper YAML_MAPPER = newObjectMapper();

public void testParseReaderWithAutoClose() throws IOException {
ObjectMapper yamlMapper = newObjectMapper();

CloseTrackerReader reader = new CloseTrackerReader("foo:bar");
yamlMapper.readTree(reader);
YAML_MAPPER.readTree(reader);

Assert.assertEquals(true, reader.isClosed());
}

public void testParseStreamWithAutoClose() throws IOException {
ObjectMapper yamlMapper = newObjectMapper();

CloseTrackerOutputStream stream = new CloseTrackerOutputStream("foo:bar");
yamlMapper.readTree(stream);
YAML_MAPPER.readTree(stream);

Assert.assertEquals(true, stream.isClosed());
}

@SuppressWarnings("deprecation")
public void testParseReaderWithoutAutoClose() throws IOException {
ObjectMapper yamlMapper = newObjectMapper()
.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);

CloseTrackerReader reader = new CloseTrackerReader("foo:bar");
yamlMapper.readTree(reader);
YAML_MAPPER.reader()
.without(JsonParser.Feature.AUTO_CLOSE_SOURCE)
.readTree(reader);

Assert.assertEquals(false, reader.isClosed());
}


@SuppressWarnings("deprecation")
public void testParseStreamWithoutAutoClose() throws IOException {
ObjectMapper yamlMapper = newObjectMapper()
.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);

CloseTrackerOutputStream stream = new CloseTrackerOutputStream("foo:bar");
yamlMapper.readTree(stream);
YAML_MAPPER.reader()
.without(JsonParser.Feature.AUTO_CLOSE_SOURCE)
.readTree(stream);

Assert.assertEquals(false, stream.isClosed());
}
Expand All @@ -72,7 +66,6 @@ public boolean isClosed() {
}
}


public static class CloseTrackerOutputStream extends ByteArrayInputStream {
private boolean closed;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.fasterxml.jackson.dataformat.yaml.deser;

import java.io.StringWriter;
import java.math.BigInteger;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLParser;

import java.io.StringWriter;
import java.math.BigInteger;

/**
* Unit tests for checking functioning of the underlying
* parser implementation.
*/
public class StreamingParseTest extends ModuleTestBase
{
final YAMLFactory YAML_F = new YAMLFactory();
private final YAMLFactory YAML_F = new YAMLFactory();

public void testBasic() throws Exception
{
Expand Down Expand Up @@ -300,16 +300,19 @@ public void testIntParsingUnderscoresSm() throws Exception
p.close();
}

// for [dataformats-text#146]
public void testYamlLongWithUnderscores() throws Exception
{
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
LongHolder longHolder = mapper.readValue("v: 1_000_000", LongHolder.class);
assertNotNull(longHolder);
assertEquals(LongHolder.class, longHolder.getClass());
assertEquals(Long.valueOf(1000000), longHolder.getV());
try (JsonParser p = YAML_F.createParser("v: 1_000_000")) {
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("v", p.currentName());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(1000000, p.getIntValue());
}
}

// [cbor#4]: accidental recognition as double, with multiple dots
// accidental recognition as double, with multiple dots
public void testDoubleParsing() throws Exception
{
// First, test out valid use case.
Expand Down Expand Up @@ -581,19 +584,4 @@ public void testTimeLikeValues() throws Exception
assertNull(p.nextToken());
p.close();
}

static class LongHolder
{
private Long v;

public Long getV()
{
return v;
}

public void setV(Long v)
{
this.v = v;
}
}
}

0 comments on commit e3c6b4b

Please sign in to comment.