Skip to content

Commit 607b058

Browse files
committed
Merge branch '2.8'
2 parents b8c02d0 + 53888b9 commit 607b058

File tree

5 files changed

+106
-6
lines changed

5 files changed

+106
-6
lines changed

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AmbiguousUnionWriteTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public class AmbiguousUnionWriteTest extends AvroTestBase
2424
);
2525

2626
static class StringWrapper {
27-
public String value;
27+
public Object value;
2828

29-
public StringWrapper(String v) { value = v; }
29+
public StringWrapper(Object v) { value = v; }
3030
protected StringWrapper() { }
3131
}
3232

@@ -41,9 +41,12 @@ protected StringWrapper() { }
4141
public void testWriteNoAmbiguity() throws Exception
4242
{
4343
AvroSchema schema = MAPPER.schemaFrom(SCHEMA_WITH_AMBIGUITY);
44+
StringWrapper input = new StringWrapper("foobar");
45+
// 23-Aug-2017, tatu: we could trigger exception with this, however:
46+
// StringWrapper input = new StringWrapper(new java.util.HashMap<String,Integer>());
4447
byte[] b = MAPPER.writerFor(StringWrapper.class)
4548
.with(schema)
46-
.writeValueAsBytes(new StringWrapper("foobar"));
49+
.writeValueAsBytes(input);
4750
StringWrapper output = MAPPER.readerFor(StringWrapper.class)
4851
.with(schema)
4952
.readValue(b);

protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadSimpleTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ public NamedStrings(String n, String... v) {
4949
}
5050
}
5151

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

58+
final ObjectMapper MAPPER = new ProtobufMapper();
59+
6060
public void testReadPointInt() throws Exception
6161
{
6262
ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.fasterxml.jackson.dataformat.protobuf;
2+
3+
import com.fasterxml.jackson.annotation.*;
4+
5+
import com.fasterxml.jackson.core.*;
6+
7+
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema;
8+
9+
public class ReadUnkownFieldsTest extends ProtobufTestBase
10+
{
11+
static class OneField {
12+
13+
@JsonProperty(value = "f3", index = 3)
14+
private int f3;
15+
16+
public int getF3() {
17+
return f3;
18+
}
19+
20+
public void setF3(int f3) {
21+
this.f3 = f3;
22+
}
23+
}
24+
25+
static class ThreeField {
26+
27+
@JsonProperty(value = "f1", index = 1)
28+
private int f1;
29+
30+
@JsonProperty(value = "f2", index = 2)
31+
private int f2;
32+
33+
@JsonProperty(value = "f3", index = 3)
34+
private int f3;
35+
36+
public int getF1() {
37+
return f1;
38+
}
39+
40+
public void setF1(int f1) {
41+
this.f1 = f1;
42+
}
43+
44+
public int getF2() {
45+
return f2;
46+
}
47+
48+
public void setF2(int f2) {
49+
this.f2 = f2;
50+
}
51+
52+
public int getF3() {
53+
return f3;
54+
}
55+
56+
public void setF3(int f3) {
57+
this.f3 = f3;
58+
}
59+
}
60+
61+
/*
62+
/**********************************************************
63+
/* Test methods
64+
/**********************************************************
65+
*/
66+
67+
final ProtobufMapper MAPPER = new ProtobufMapper();
68+
69+
public void testMultipleUnknown() throws Exception
70+
{
71+
ProtobufMapper mapper = new ProtobufMapper();
72+
73+
ThreeField threeField = new ThreeField();
74+
threeField.setF1(1);
75+
threeField.setF2(2);
76+
threeField.setF3(3);
77+
78+
ProtobufSchema schemaWith3 = MAPPER.generateSchemaFor(ThreeField.class);
79+
byte[] in = mapper.writerFor(ThreeField.class).with(schemaWith3)
80+
.writeValueAsBytes(threeField);
81+
82+
ProtobufSchema schemaWith1 = MAPPER.generateSchemaFor(OneField.class);
83+
OneField oneField = mapper.readerFor(OneField.class).with(schemaWith1)
84+
// important: skip through unknown
85+
.with(JsonParser.Feature.IGNORE_UNDEFINED)
86+
.readValue(in);
87+
88+
assertEquals(threeField.getF3(), oneField.getF3());
89+
}
90+
}

release-notes/CREDITS

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ marsqing@github
2626
(2.8.9)
2727
* Reported #94: (protobuf) Should _ensureRoom in ProtobufGenerator.writeString()
2828
(2.8.10)
29+
* Reported #106 (protobuf), contributed fix for: calling _skipUnknownValue() twice
30+
(2.8.11 / 2.9.1)
2931

3032
baharclerode@github:
3133

release-notes/VERSION

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ Modules:
3838
(reported by coder-hub@github)
3939
- (avro): Upgrade `avro-core` dep from 1.7.7 to 1.8.1
4040

41-
2.8.10 (not yet released)
41+
2.8.11 (not yet released)
42+
43+
#106: fix calling _skipUnknownValue() twice
44+
(reported, contributed fix for by marsqing@github@github)
45+
46+
2.8.10 (24-Aug-2017)
4247

4348
#94: Should _ensureRoom in ProtobufGenerator.writeString()
4449
(reported by marsqing@github)

0 commit comments

Comments
 (0)