Skip to content

Commit 36f2f2a

Browse files
committed
Fix #74
1 parent 50da813 commit 36f2f2a

File tree

7 files changed

+63
-10
lines changed

7 files changed

+63
-10
lines changed

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/ser/GeneratorIgnoreUnknown51Test.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import java.util.*;
55

66
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
7-
import com.fasterxml.jackson.annotation.JsonValue;
7+
88
import com.fasterxml.jackson.core.JsonGenerator;
9+
910
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
1011
import com.fasterxml.jackson.dataformat.csv.CsvMappingException;
1112
import com.fasterxml.jackson.dataformat.csv.CsvSchema;

properties/src/main/java/com/fasterxml/jackson/dataformat/javaprop/JavaPropsParser.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class JavaPropsParser extends ParserMinimalBase
5050
/* Parsing state
5151
/**********************************************************
5252
*/
53-
53+
5454
protected JPropReadContext _readContext;
5555

5656
protected boolean _closed;
@@ -60,11 +60,11 @@ public class JavaPropsParser extends ParserMinimalBase
6060
/* Recycled helper objects
6161
/**********************************************************
6262
*/
63-
63+
6464
protected ByteArrayBuilder _byteArrayBuilder;
65-
65+
6666
protected byte[] _binaryValue;
67-
67+
6868
/*
6969
/**********************************************************
7070
/* Life-cycle
@@ -209,7 +209,7 @@ public String getCurrentName() throws IOException {
209209

210210
@Override
211211
public JsonToken nextToken() throws IOException {
212-
212+
_binaryValue = null;
213213
if (_readContext == null) {
214214
if (_closed) {
215215
return null;
@@ -225,7 +225,6 @@ public JsonToken nextToken() throws IOException {
225225
System.err.println("\n>>");
226226
*/
227227
}
228-
229228
while ((_currToken = _readContext.nextToken()) == null) {
230229
_readContext = _readContext.nextContext();
231230
if (_readContext == null) { // end of content

properties/src/test/java/com/fasterxml/jackson/dataformat/javaprop/ArrayParsingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ static class StringArrayWrapper {
4949
public String[] str;
5050
}
5151

52-
private final ObjectMapper MAPPER = mapperForProps();
53-
5452
/*
5553
/**********************************************************************
5654
/* Test methods
5755
/**********************************************************************
5856
*/
5957

58+
private final ObjectMapper MAPPER = mapperForProps();
59+
6060
public void testArrayWithBranch() throws Exception
6161
{
6262
// basically "extra" branch should become as first element, and
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.fasterxml.jackson.dataformat.javaprop;
2+
3+
import static org.junit.Assert.assertArrayEquals;
4+
5+
import java.nio.ByteBuffer;
6+
import java.util.Properties;
7+
8+
public class BinaryParsingTest extends ModuleTestBase
9+
{
10+
// [dataformats-text#74]: problem with multiple binary fields
11+
static class MyBean {
12+
public byte[] a;
13+
public byte[] b;
14+
public ByteBuffer c;
15+
16+
protected MyBean() { }
17+
public MyBean(boolean bogus) {
18+
a = new byte[] { 1 };
19+
b = new byte[] { 3, 28, 7 };
20+
c = ByteBuffer.wrap(new byte[] { 1, 2, 3, 4, 5, 67 });
21+
}
22+
}
23+
24+
/*
25+
/**********************************************************************
26+
/* Test methods
27+
/**********************************************************************
28+
*/
29+
30+
private final JavaPropsMapper MAPPER = mapperForProps();
31+
32+
// [dataformats-text#74]
33+
public void testMultipleBinaryFields() throws Exception
34+
{
35+
MyBean src = new MyBean(true);
36+
Properties props = MAPPER.writeValueAsProperties(src);
37+
38+
MyBean result = MAPPER.readPropertiesAs(props, MyBean.class);
39+
assertArrayEquals(src.a, result.a);
40+
assertArrayEquals(src.b, result.b);
41+
ByteBuffer b1 = src.c;
42+
ByteBuffer b2 = result.c;
43+
44+
assertEquals(b1, b2);
45+
}
46+
}

release-notes/CREDITS renamed to release-notes/CREDITS-2.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ Mike Kobit (mkobit@github.com)
1515

1616
* Reported #65 (yaml): `YAMLParser` incorrectly handles numbers with underscores in them
1717
(2.9.4)
18+
19+
Fabrice Delhoste (spifd@github)
20+
21+
* Reported #74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties
22+
(2.9.5)
23+

release-notes/VERSION renamed to release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Modules:
1414
(reported by mbechler@github)
1515
#65 (yaml): `YAMLParser` incorrectly handles numbers with underscores in them
1616
(reported by Mike K)
17+
#74 (properties): `JavaPropsMapper` issue deserializing multiple byte array properties
18+
(reported by Fabrice D)
1719

1820
2.9.3 (09-Dec-2017)
1921

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorFeature34Test.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
66
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
77
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
8-
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
98

109
public class GeneratorFeature34Test extends ModuleTestBase
1110
{

0 commit comments

Comments
 (0)