qickrooms / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
0 stars 0 forks source link

Modifying the Collection Passed to ofy().save() #197

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Modifying the collection passed to ofy().save() can cause strange results.  It 
took me a very long time to isolate this problem.  I would like to request 
either "fixing" it, or documenting that the collection should not be modified 
before the results are fetched.

Here is code to show unexpected results:

@Entity
@Cache
public static class TestObj {
    @Id public long id = (long) (Math.random() * 10000);
}

TestObj obj = new TestObj();
ofy().load().entity(obj).now(); // <-- this is necessary
Collection toSave = new ArrayList();
toSave.add(obj);
Result result = ofy().save().entities(toSave);
toSave.clear(); // <-- this is what breaks things
result.now();
ofy().load().entity(obj).now(); // <-- return "null"

Original issue reported on code.google.com by ersim...@gmail.com on 24 Apr 2014 at 11:41

GoogleCodeExporter commented 9 years ago
Interesting. Let's consider that a bug.

Original comment by lhori...@gmail.com on 24 Apr 2014 at 11:54

GoogleCodeExporter commented 9 years ago
Fixed in 5.0.3

Original comment by lhori...@gmail.com on 30 Apr 2014 at 6:46

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by ersim...@gmail.com on 30 Apr 2014 at 6:48