diff --git a/Parse/src/main/java/com/parse/ParseObject.java b/Parse/src/main/java/com/parse/ParseObject.java index 113421ea9..a2f98fd7b 100644 --- a/Parse/src/main/java/com/parse/ParseObject.java +++ b/Parse/src/main/java/com/parse/ParseObject.java @@ -306,7 +306,6 @@ public String toString() { // Cached State private final Map estimatedData; - private final Map dataAvailability; private final Map hashedObjects; // For mutable containers private String localId; @@ -385,7 +384,6 @@ public ParseObject(String theClassName) { operationSetQueue.add(new ParseOperationSet()); estimatedData = new HashMap<>(); hashedObjects = new IdentityHashMap<>(); - dataAvailability = new HashMap<>(); State.Init builder = newStateBuilder(theClassName); // When called from new, assume hasData for the whole object is true. @@ -754,7 +752,6 @@ private void setState(State newState, boolean notifyIfObjectIdChanges) { } rebuildEstimatedData(); - rebuildDataAvailability(); checkpointAllMutableContainers(); } } @@ -843,7 +840,6 @@ public Set keySet() { synchronized (mutex) { currentOperations().remove(key); rebuildEstimatedData(); - rebuildDataAvailability(); checkpointAllMutableContainers(); } } @@ -856,7 +852,6 @@ public Set keySet() { synchronized (mutex) { currentOperations().clear(); rebuildEstimatedData(); - rebuildDataAvailability(); checkpointAllMutableContainers(); } } @@ -2959,18 +2954,6 @@ private void rebuildEstimatedData() { } } - /** - * Regenerates the dataAvailability map from the serverData. - */ - private void rebuildDataAvailability() { - synchronized (mutex) { - dataAvailability.clear(); - for (String key : state.keySet()) { - dataAvailability.put(key, true); - } - } - } - /** * performOperation() is like {@link #put(String, Object)} but instead of just taking a new value, * it takes a ParseFieldOperation that modifies the value. @@ -2990,7 +2973,6 @@ private void rebuildDataAvailability() { currentOperations().put(key, newOperation); checkpointMutableContainer(key, newValue); - dataAvailability.put(key, Boolean.TRUE); } } @@ -3546,8 +3528,7 @@ public boolean isDataAvailable() { private boolean isDataAvailable(String key) { synchronized (mutex) { - return isDataAvailable() - || (dataAvailability.containsKey(key) ? dataAvailability.get(key) : false); + return isDataAvailable() || estimatedData.containsKey(key); } } diff --git a/Parse/src/test/java/com/parse/ParseObjectTest.java b/Parse/src/test/java/com/parse/ParseObjectTest.java index 65b83ccee..1dcceeeac 100644 --- a/Parse/src/test/java/com/parse/ParseObjectTest.java +++ b/Parse/src/test/java/com/parse/ParseObjectTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class ParseObjectTest { @@ -73,6 +74,16 @@ public void testFromJSONPayloadWithoutClassname() throws JSONException { //region testGetter + @Test( expected = IllegalStateException.class ) + public void testGetUnavailable() { + ParseObject.State state = mock(ParseObject.State.class); + when(state.className()).thenReturn("TestObject"); + when(state.isComplete()).thenReturn(false); + + ParseObject object = ParseObject.from(state); + object.get("foo"); + } + @Test public void testGetList() throws Exception { ParseObject object = new ParseObject("Test");