Skip to content

Actual types passed to generic POJO super classes and to generic collection fields are ignored #5334

Open
@eranl

Description

@eranl

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Giraffe | 2022.3.1 Patch 1
  • Firebase Component: Firestore
  • Component version: 24.6.1

[REQUIRED] Step 3: Describe the problem

Given the classes

  class BaseBean<T> {
    public T value;
  }

  class SubBean extends BaseBean<String> {}

if you try to deserialize into the sub-bean, you get java.lang.IllegalStateException: Could not resolve type T. Same is true for a base bean with a setter that takes a T parameter.

While debugging this, I found that given the classes

  class MapBean<T> {
    public Map<String, T> values;
  }

  class MapSubBean extends MapBean<String> {}

  class MapBeanHolder {
    public MapBean<String> map;
  }

deserializing into MapSubBean or MapBeanHolder, the code errs on the lenient side, and would accept any type of values into the values map.

I have a proposed backward-compatible fix for both issues. Should I post a PR?

I have posted this bug and the corresponding PR on the other version of this library (googleapis/java-firestore#1313 & googleapis/java-firestore#1323 respectively).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions