Commit f2e6475
Fix StackOverflowError when merging ParseObject from JSON (#925)
* Add test for StackOverflowError during mergeFromServer
This test shows the #896 bug.
* Make a synchronized copy of availableKeys
`synchronizedSet(s)` ends up making a new wrapper for the supplied set, which
means on subsequent calls, it becomes a SynchronizedSet, wrapped in a
SynchronizedSet, wrapped ... etc.
When using the LocalDataStore, the ParseObject.State is reused for every
matching ClassName+ObjectId pair, so every time a ParseObject is parsed from
JSON data, the existing object is "refreshed" by making a copy of its State,
and then merging with the new data. Every call to State.newBuilder() is
therefore adding a new layer of SynchronizedSet to the availableKeys Set.
Eventually that nested hierarchy of sets becomes so large that it causes a
StackOverflowError for any operation on the collection.
By making a copy of the set before wrapping it in synchronizedSet(), that
nested hierarchy becomes severed, and we end up with just one level of
wrappers.
* Accept the updated Android Build-Tools 27 license1 parent 5bd91aa commit f2e6475
File tree
3 files changed
+28
-3
lines changed- parse/src
- main/java/com/parse
- test/java/com/parse
3 files changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4076 | 4076 | | |
4077 | 4077 | | |
4078 | 4078 | | |
4079 | | - | |
| 4079 | + | |
4080 | 4080 | | |
4081 | 4081 | | |
4082 | 4082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
140 | 165 | | |
141 | 166 | | |
142 | 167 | | |
| |||
0 commit comments