Skip to content

Commit c94dbef

Browse files
MichalFoksaMichal Foksa
andauthored
#281: Since 2.13, UnsupportedOperationException is thrown instead of InvalidDefinitionException. Reason in 2.13 in that ToEmptyObjectSerializer is used to serialize java.util.Map which calls visitor.expectObjectFormat(typeHint) and thus different exception is thrown at the end and when schema is requested from mapper. (#282)
Co-authored-by: Michal Foksa <[email protected]>
1 parent 79f9215 commit c94dbef

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/TestSimpleGeneration.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static class RootType
1818
{
1919
@JsonAlias({"nm", "Name"})
2020
public String name;
21-
21+
2222
public int value;
23-
23+
2424
List<String> other;
2525
}
2626

@@ -51,7 +51,7 @@ public ByteBuffer getBytes() {
5151
}
5252
}
5353
}
54-
54+
5555
/*
5656
/**********************************************************
5757
/* Tests
@@ -94,21 +94,21 @@ public void testEmployee() throws Exception
9494
AvroSchema schema = gen.getGeneratedSchema();
9595
assertNotNull(schema);
9696

97-
String json = schema.getAvroSchema().toString(true);
97+
String json = schema.getAvroSchema().toString(true);
9898
assertNotNull(json);
9999
AvroSchema s2 = MAPPER.schemaFrom(json);
100100
assertNotNull(s2);
101-
101+
102102
Employee empl = new Employee();
103103
empl.name = "Bobbee";
104104
empl.age = 39;
105105
empl.emails = new String[] { "[email protected]", "[email protected]" };
106106
empl.boss = null;
107-
107+
108108
// So far so good: try producing actual Avro data...
109109
byte[] bytes = MAPPER.writer(schema).writeValueAsBytes(empl);
110110
assertNotNull(bytes);
111-
111+
112112
// and bring it back, too
113113
Employee e2 = getMapper().readerFor(Employee.class)
114114
.with(schema)
@@ -131,7 +131,7 @@ public void testMap() throws Exception
131131
assertNotNull(s2);
132132

133133
// should probably verify, maybe... ?
134-
134+
135135
// System.out.println("Map schema:\n"+json);
136136
}
137137

@@ -165,10 +165,8 @@ public void testSchemaForUntypedMap() throws Exception
165165
try {
166166
MAPPER.schemaFor(Map.class);
167167
fail("Not expected to work yet");
168-
} catch (InvalidDefinitionException e) {
169-
verifyException(e, "\"Any\" type");
170-
verifyException(e, "not supported");
171-
verifyException(e, "`java.lang.Object`");
168+
} catch (UnsupportedOperationException e) {
169+
verifyException(e, "Maps with non-stringable keys are not supported yet");
172170
}
173171
}
174172
}

0 commit comments

Comments
 (0)