Skip to content

Ignore null lists in MessageJsonAdapter#fromJson #3353

@jisungbin

Description

@jisungbin

In MessageJsonAdapter#fromJson, we ignore null values with if (value == null) continue. But if the deserialized value is a List<T?> whose some element is null, we still call fieldBinding.set(builder, value).

Image

Later, when the T message is built, immutableCopyOf("…", list) checks require(null !in result) and throws an IllegalArgumentException because the list contains a null entry.

Image

Is it okay to open a PR that updates fromJson to skip lists where every element is null, or to only include non-null elements?

EDIT: I initially thought we could simply remove nulls, but there are cases—like repeated google.protobuf.NullValue—where null is officially permitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions