Skip to content

Commit 036fe28

Browse files
committed
Add unit test for FasterXML#999
1 parent f686856 commit 036fe28

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@JacksonStdImpl // since 2.6. NOTE: sub-classes typically are not
3737
public class BeanPropertyWriter
3838
extends PropertyWriter // which extends `ConcreteBeanPropertyBase`
39-
implements java.io.Serializable // since 2.6.2
39+
implements java.io.Serializable // since 2.6
4040
{
4141
// As of 2.7
4242
private static final long serialVersionUID = 1L;
@@ -582,7 +582,7 @@ public JavaType getFullPropertyType() {
582582
*/
583583

584584
/**
585-
* @deprecated Since 2.7, to be removed from 2.8
585+
* @deprecated Since 2.7, to be removed from 2.8, use {@link #getType()} instead.
586586
*/
587587
@Deprecated
588588
public Class<?> getPropertyType() {
@@ -600,7 +600,7 @@ public Class<?> getPropertyType() {
600600
*
601601
* @return The property type, or null if not found.
602602
*
603-
* @deprecated Since 2.7, to be removed from 2.8
603+
* @deprecated Since 2.7, to be removed from 2.8, use {@link #getType()} instead.
604604
*/
605605
@Deprecated
606606
public Type getGenericPropertyType() {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.*;
4+
import com.fasterxml.jackson.core.type.TypeReference;
5+
import com.fasterxml.jackson.databind.*;
6+
7+
public class ExternalTypeId999Test extends BaseMapTest
8+
{
9+
public static interface Payload { }
10+
11+
@JsonTypeName("foo")
12+
public static class FooPayload implements Payload { }
13+
14+
@JsonTypeName("bar")
15+
public static class BarPayload implements Payload { }
16+
17+
public static class Message<P extends Payload>
18+
{
19+
private final String type;
20+
@JsonTypeInfo(visible = true, use = JsonTypeInfo.Id.NAME,
21+
include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "type")
22+
@JsonSubTypes({
23+
@JsonSubTypes.Type(FooPayload.class),
24+
@JsonSubTypes.Type(BarPayload.class) })
25+
private final P payload;
26+
27+
@JsonCreator
28+
public Message(@JsonProperty("type") String type,
29+
@JsonProperty("payload") P payload)
30+
{
31+
if (type == null) {
32+
throw new RuntimeException("'type' is null");
33+
}
34+
if (payload == null) {
35+
throw new RuntimeException("'payload' is null");
36+
}
37+
this.type = type;
38+
this.payload = payload;
39+
}
40+
}
41+
42+
43+
public void testExternalTypeId() throws Exception
44+
{
45+
ObjectMapper objectMapper = new ObjectMapper();
46+
Message<?> msg = objectMapper.readValue(
47+
"{ \"type\": \"foo\", \"payload\": {} }",
48+
new TypeReference<Message<FooPayload>>() { });
49+
assertNotNull(msg);
50+
}
51+
}

0 commit comments

Comments
 (0)