[JAVA-576] Setting DBEncoder for $cmd collection has no effect Created: 29/May/12 Updated: 30/Jan/15 Resolved: 10/Jun/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Philipp Heinze | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Fedora Linux 16 64bit, Mongodb 2.0.3 |
||
| Attachments: |
|
| Description |
|
When running the attached TestCase, I'll not see any outputs due to the fact that findAndModify Operations are run from the $cmd Collection. The corresponding DBApiLayer.MyCollection.__find(DBObject, DBObject, int, int, int, int, ReadPreference, DBDecoder) call is accessing OutMessage.query without handling a DBEncoder, so the driver falls back to the defaultEncoder ignoring custom set Encoders through db.getCollection("$cmd").setDBEncoderFactory(). From my point of view the driver should be set per Default to a given Encoder/Decoder(-Factory), which then can be overriden with a custom Encoder/Decoder(-Factory). Attached is as well a patch fixing this specific mentioned problem, but other locations referencing DB(En|De)coder.FACTORY should be considered for changes as well. |
| Comments |
| Comment by Githook User [ 30/Jan/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by Jeffrey Yemin [ 10/Jun/14 ] |
|
Added tests to ensure that findAndModify/findAndRemove use custom object class. |
| Comment by Githook User [ 10/Jun/14 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by Jeffrey Yemin [ 04/Jun/12 ] |
|
It is a sort of a CRUD method. I'm more trying to find out what your need for a customer encoder is in this particular case. |
| Comment by Philipp Heinze [ 30/May/12 ] |
|
I'm trying to perform something like introspection. The Unit under test consists of a function performing several tasks, one of it is updating a document with findAndModify (for atomic retrieve and update). I may be able to refactor my code so that I can check states after the findAndModify call. Anyway I'm not sure if this would always make sense. If I understand the code correctly findAndModify isn't a simple find method and there's only one command sent, which contains find and update at the same time. So I would consider it as CRUD method as well? |
| Comment by Jeffrey Yemin [ 30/May/12 ] |
|
Thanks for the bug report. Currently all of the find methods in DBCollection ignore the encoder. It's used only for insert/update. Can you describe your use case for a custom encoder for findAndModify? |