In my application I’m calling
GridFSDBFile f = gfs.findOne (new ObjectId(gridId))
This usually returns a valid file that was previously created by a call to
GridFSInputFile gridFile = gfs.createFile(someFile.getBytes())
gridFile.save()
But sometimes it returns null. So I put it in a while loop
while (!f)
{
f = gfs.findOne(new ObjectId(gridId))
Thread.sleep(200)
}
This returns a valid file after the second call after about 400 ms have elapsed. Am I doing something wrong or is there a possible delay after a file is created to the time you can access it?
Identical with http://groups.google.com/group/mongodb-user/browse_thread/thread/9b90135104b1bdeb?pli=1 and already answered there by the 10gen people – not sure why this question must be posted on a different platform where the mongo users list the likely the best platform for getting help from the official maintainers.