Skip to content

Commit ee5596c

Browse files
committed
Last part of clean up wrt Avro fixes
1 parent 7a082d0 commit ee5596c

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public final void writeEndArray() throws IOException
381381

382382
@Override
383383
public final void writeStartObject() throws IOException {
384-
_avroContext = _avroContext.createChildObjectContext();
384+
_avroContext = _avroContext.createChildObjectContext(null);
385385
_complete = false;
386386
}
387387

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ public static AvroWriteContext nullContext() {
7373

7474
public abstract AvroWriteContext createChildArrayContext(Object currValue) throws JsonMappingException;
7575

76-
public AvroWriteContext createChildObjectContext() throws JsonMappingException {
77-
return createChildObjectContext(null);
78-
}
79-
8076
public abstract AvroWriteContext createChildObjectContext(Object currValue) throws JsonMappingException;
8177

8278
public void complete() throws IOException {
@@ -211,23 +207,33 @@ protected GenericArray<Object> _createArray(Schema schema)
211207
return new GenericData.Array<Object>(8, schema);
212208
}
213209

210+
// Removed from 2.10, should not be needed any more
211+
/*
214212
protected AvroWriteContext _createObjectContext(Schema schema) throws JsonMappingException {
215213
if (schema.getType() == Type.UNION) {
216214
schema = _recordOrMapFromUnion(schema);
217215
}
218216
return _createObjectContext(schema, null); // Object doesn't matter as long as schema isn't a union
219217
}
218+
*/
220219

221220
protected AvroWriteContext _createObjectContext(Schema schema, Object currValue)
222221
throws JsonMappingException
223222
{
224223
Type type = schema.getType();
225224
if (type == Schema.Type.UNION) {
226-
try {
227-
schema = resolveUnionSchema(schema, currValue);
228-
} catch (UnresolvedUnionException e) {
229-
// couldn't find an exact match
225+
// 14-Aug-2019, tatu: Mapping null is bit special; and without special handling
226+
// we get an exception after fix for [dataformats-binary#168]
227+
// ... but I am not sure I fully understand what or why, actually.
228+
if (currValue == null) {
230229
schema = _recordOrMapFromUnion(schema);
230+
} else {
231+
try {
232+
schema = resolveUnionSchema(schema, currValue);
233+
} catch (UnresolvedUnionException e) {
234+
// couldn't find an exact match
235+
schema = _recordOrMapFromUnion(schema);
236+
}
231237
}
232238
type = schema.getType();
233239
}

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/ObjectWriteContext.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ public final AvroWriteContext createChildArrayContext(Object currValue)
4747
return child;
4848
}
4949

50-
@Override
51-
public AvroWriteContext createChildObjectContext() throws JsonMappingException {
52-
_verifyValueWrite();
53-
Schema.Field field = _findField();
54-
if (field == null) { // unknown, to ignore
55-
return new NopWriteContext(TYPE_OBJECT, this, _generator, null);
56-
}
57-
AvroWriteContext child = _createObjectContext(field.schema());
58-
_record.put(_currentName, child.rawValue());
59-
return child;
60-
}
61-
6250
@Override
6351
public AvroWriteContext createChildObjectContext(Object currValue) throws JsonMappingException {
6452
_verifyValueWrite();

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/GeneratorDeepNestingTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.fasterxml.jackson.dataformat.cbor;
22

33
import java.io.ByteArrayOutputStream;
4-
import java.io.OutputStream;
54
import java.util.*;
65

76
import com.fasterxml.jackson.core.JsonGenerator;

0 commit comments

Comments
 (0)