parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 734 forks source link

StackOverflow when parsing a very long text #1053

Open abraaocaldas opened 4 years ago

abraaocaldas commented 4 years ago

Parse Android SDK : 1.25.0

Using Android 10 platform

If you try to create a ParseObject with a string that is too big (have many lines), the serializer drops a stackoverflow exception.

public <T extends ParseObject.State> JSONObject encode(
            T state, ParseOperationSet operations, ParseEncoder encoder) {
        JSONObject objectJSON = new JSONObject();

        try {
            // Serialize the data
            for (String key : operations.keySet()) {
                ParseFieldOperation operation = operations.get(key);
                objectJSON.put(key, encoder.encode(operation));

                // TODO(grantland): Use cached value from hashedObjects if it's a set operation.
            }

            if (state.objectId() != null) {
                objectJSON.put(KEY_OBJECT_ID, state.objectId());
            }
        } catch (JSONException e) {
            throw new RuntimeException("could not serialize object to JSON");
        }

The exception inside objectJSON is good to debug but the exception thrown by catch block is useless when debugging.

Jawnnypoo commented 4 years ago

Do you think you could create a test that reproduces this and submit it as a PR?