Commit c575524
committed
Properly decode JSONObject.NULL => null [Fixes #209]
ParseEncoder encodes (null) => JSONObject.NULL. But ParseDecoder was not
doing the inverse conversion.
That resulted in JSONObject.NULL values being in the ParseObject.State map,
which means any calls to State.get(key) that were casting the result to a
specific type (i.e., String) without first checking the Object return type
would result in a ClassCastException.
ParseObject already accounts for this possibility by checking the Object type
before casting it, and returning null if the type did not match.
The known case that causes crashes is #209, where ParseUser.State.sessionToken()
casts the result of get(KEY_SESSION_TOKEN) to String. When that was null it
would be encoded as JSONObject.NULL due to the ParseEncoder; but after decoding
it would not convert back to a native null, leading to the ClassCastException.1 parent 3cc9570 commit c575524
File tree
2 files changed
+10
-0
lines changed- Parse/src
- main/java/com/parse
- test/java/com/parse
2 files changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
0 commit comments