Skip to content

Commit

Permalink
Problem with Must access entries in sequence (#657)
Browse files Browse the repository at this point in the history
* Problem with `Must access entries in sequence`

* fix

---------

Co-authored-by: yawkat <jonas.konrad@oracle.com>
  • Loading branch information
dstepanov and yawkat authored Nov 9, 2023
1 parent 5c5ced0 commit 7b3863b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package io.micronaut.serde.jackson.annotation

import com.fasterxml.jackson.annotation.JsonTypeInfo
import io.micronaut.context.ApplicationContextBuilder
import io.micronaut.core.type.Argument
import io.micronaut.serde.jackson.JsonCompileSpec
import spock.lang.Unroll

class JsonTypeInfoSpec extends JsonCompileSpec {

@Override
protected void configureContext(ApplicationContextBuilder contextBuilder) {
super.configureContext(contextBuilder.properties(
Map.of("micronaut.serde.deserialization.ignore-unknown", "false")
))
}

void "test default implementation - with @DefaultImplementation"() {
given:
def context = buildContext("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ private Object deserialize(Decoder decoder, DecoderContext decoderContext, Argum
Decoder objectDecoder = decoder.decodeObject(type);

Object instance = null;
boolean completed = false;
while (true) {
final String propertyName = objectDecoder.decodeKey();
if (propertyName == null) {
completed = true;
break;
}
if (deserBean.ignoredProperties != null && deserBean.ignoredProperties.contains(propertyName)) {
Expand All @@ -102,7 +104,7 @@ private Object deserialize(Decoder decoder, DecoderContext decoderContext, Argum
if (deserBean.ignoreUnknown) {
objectDecoder.finishStructure(true);
} else {
if (deserBean.ignoredProperties != null) {
if (deserBean.ignoredProperties != null && !completed) {
String key = objectDecoder.decodeKey();
while (key != null) {
handleUnknownProperty(type, objectDecoder, key, deserBean);
Expand Down

0 comments on commit 7b3863b

Please sign in to comment.