@@ -239,6 +239,31 @@ public void testHandlesSetMutationThenDocument() {
239
239
assertContains (doc ("foo/bar" , 2 , map ("foo" , "bar" ), true ));
240
240
}
241
241
242
+ @ Test
243
+ public void testHandlesSetMutationThenAckThenRelease () {
244
+ Query query = Query .atPath (ResourcePath .fromSegments (asList ("foo" )));
245
+ allocateQuery (query );
246
+
247
+ writeMutation (setMutation ("foo/bar" , map ("foo" , "bar" )));
248
+ assertChanged (doc ("foo/bar" , 0 , map ("foo" , "bar" ), true ));
249
+ assertContains (doc ("foo/bar" , 0 , map ("foo" , "bar" ), true ));
250
+
251
+ acknowledgeMutation (1 );
252
+ notifyLocalViewChanges (viewChanges (2 , asList ("foo/bar" ), emptyList ()));
253
+
254
+ assertChanged ();
255
+ assertContains (doc ("foo/bar" , 0 , map ("foo" , "bar" ), true ));
256
+
257
+ releaseQuery (query );
258
+
259
+ // It has been acknowledged, and should no longer be retained as there is no target and mutation
260
+ if (garbageCollectorIsEager ()) {
261
+ assertNotContains ("foo/bar" );
262
+ } else {
263
+ assertContains (doc ("foo/bar" , 0 , map ("foo" , "bar" ), false ));
264
+ }
265
+ }
266
+
242
267
@ Test
243
268
public void testHandlesAckThenRejectThenRemoteEvent () {
244
269
// Start a query that requires acks to be held.
0 commit comments