Skip to content

Commit

Permalink
Fix #104
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 2, 2023
1 parent 3e33f24 commit 34e308f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ private T deserializeContents(JsonParser p, DeserializationContext ctxt)

JsonToken currToken = p.currentToken();
if (currToken != JsonToken.FIELD_NAME) {
expect(p, JsonToken.START_OBJECT);
currToken = p.nextToken();
// 01-Mar-2023, tatu: [datatypes-collections#104] Handle empty Maps too
if (currToken != JsonToken.END_OBJECT) {
expect(p, JsonToken.START_OBJECT);
currToken = p.nextToken();
}

This comment has been minimized.

Copy link
@magical-l

magical-l Mar 2, 2023

Contributor

when the currToken==JsonToken.END_OBJECT, do we need to consume it too(by calling p.nextToken())? or maybe there another exception late when deserialize the properties after this multimap in the outside object? just a little confusion...

This comment has been minimized.

Copy link
@cowtowncoder

cowtowncoder Mar 3, 2023

Author Member

No; deserializers should only advanced token stream (parser) to tokens they handle. This is how things would work in cases where we do not encounter END_OBJECT but iterate over FIELD_NAME and value tokens, ending iteration upon entering END_OBJECT (or rather, not finding any more FIELD_NAMEs).

But a bigger question is why do we encounter END_OBJECT as the current token. I forget details but I think it has to do with polymorphic deserialization (and perhaps buffering).

}

for (; currToken == JsonToken.FIELD_NAME; currToken = p.nextToken()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.fasterxml.jackson.datatype.guava.failing;
package com.fasterxml.jackson.datatype.guava;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.guava.ModuleTestBase;
import com.google.common.collect.ArrayListMultimap;

public class MultiMap104Test extends ModuleTestBase
Expand Down
6 changes: 6 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Active Maintainers:
=== Releases ===
------------------------------------------------------------------------

2.14.3 (not yet released)

#104: `ArrayListMultimapDeserializer` does not support multimaps inside
another object as a property
(reported by @magical-l)

2.14.2 (28-Jan-2023)
2.14.1 (21-Nov-2022)

Expand Down

0 comments on commit 34e308f

Please sign in to comment.