Skip to content

Commit

Permalink
Fix #2077
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 21, 2019
1 parent 8cec7af commit c7e12f4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ Sadayuki Furuhashi (frsyuki@github)
* Reported #941: Deserialization from "{}" to ObjectNode field causes
"out of END_OBJECT token" error
(2.6.3)
* Reported #2077: `JsonTypeInfo` with a subtype having `JsonFormat.Shape.ARRAY`
and no fields generates `{}` not `[]`
(2.10.0)
David Haraburda (dharaburda@github)
* Contributed #918: Add `MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING`
Expand Down
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Project: jackson-databind

2.10.0 (not yet released)

#2077: `JsonTypeInfo` with a subtype having `JsonFormat.Shape.ARRAY` and
no fields generates `{}` not `[]`
(reported by Sadayuki F)
#2466: Didn't find class "java.nio.file.Path" below Android api 26
(reported by KevynBct@github)
#2467: Accept `JsonTypeInfo.As.WRAPPER_ARRAY` with no second argument to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,25 @@ protected BeanSerializer(BeanSerializerBase src, Set<String> toIgnore) {
*/

/**
* Method for constructing dummy bean serializer; one that
* never outputs any properties
* @deprecated Since 2.10
*/
@Deprecated
public static BeanSerializer createDummy(JavaType forType)
{
return new BeanSerializer(forType, null, NO_PROPS, null);
}

/**
* Method for constructing dummy bean serializer; one that
* never outputs any properties
*
* @since 2.10
*/
public static BeanSerializer createDummy(JavaType forType, BeanSerializerBuilder builder)
{
return new BeanSerializer(forType, builder, NO_PROPS, null);
}

@Override
public JsonSerializer<Object> unwrappingSerializer(NameTransformer unwrapper) {
return new UnwrappingBeanSerializer(this, unwrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ public JsonSerializer<?> build()
* type information)
*/
public BeanSerializer createDummy() {
return BeanSerializer.createDummy(_beanDesc.getType());
// 20-Sep-2019, tatu: Can not skimp on passing builder (see [databind#2077])
return BeanSerializer.createDummy(_beanDesc.getType(), this);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder,
_props = properties;
_filteredProps = filteredProperties;
if (builder == null) { // mostly for testing
// 20-Sep-2019, tatu: Actually not just that but also "dummy" serializer for
// case of no bean properties, too
_typeId = null;
_anyGetterWriter = null;
_propertyFilterId = null;
Expand Down Expand Up @@ -414,7 +416,7 @@ public JsonSerializer<?> createContextual(SerializerProvider provider,
final AnnotatedMember accessor = (property == null || intr == null)
? null : property.getMember();
final SerializationConfig config = provider.getConfig();

// Let's start with one big transmutation: Enums that are annotated
// to serialize as Objects may want to revert
JsonFormat.Value format = findFormatOverrides(provider, property, handledType());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.fasterxml.jackson.failing;
package com.fasterxml.jackson.databind.struct;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

public class TestPOJOAsArrayPolymorphic2077 extends BaseMapTest
public class TestPOJOAsArrayPolymorphic extends BaseMapTest
{
// [databind#2077]
@JsonTypeInfo(
Expand Down

0 comments on commit c7e12f4

Please sign in to comment.