Skip to content

FR: Add Support for Collections #78

@Rossiar

Description

@Rossiar

Add support to the Firebase Admin SDK for any Collection - they all provide an iterator() so I don't see why it is a problem to do this.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Microsoft Windows 10 Pro 10.0.15063
  • Firebase SDK version: 5.3.1
  • Firebase Product: realtime database

[REQUIRED] Step 3: Describe the problem

I am trying to serialize a Set using Firebase and it is throwing Serializing Collections is not supported, please use Lists instead due to this throw statement

Steps to reproduce:

Attempt to serialize a Set with the Firebase Admin SDK

Relevant Code:

Here is a JUnit 4.0 test that produces the error:

import com.google.firebase.database.DatabaseException;
import com.google.firebase.database.utilities.encoding.CustomClassMapper;
import org.junit.Test;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;

public class FirebaseTest {

    @Test
    public void firebaseCannotSerializeSets() throws Exception {
        Map<String, Object> data = new HashMap<>();
        data.put("myset", Collections.singleton("1"));

        try {
            CustomClassMapper.convertToPlainJavaTypes(data);
        } catch (DatabaseException e) {
            assertEquals("Serializing Collections is not supported, " +
                    "please use Lists instead", e.getMessage());
        }
    }
}

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