[JAVA-689] DBCursor isn't thread-safe ! Created: 06/Nov/12 Updated: 06/Apr/23 Resolved: 08/Nov/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.9.1, 2.9.2, 2.9.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mark Henzel | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
openjdk 7 on linux x64 |
||
| Description |
|
The DBCursor object of the java driver api doesn't seem to be thread-safe: I execute dbcursorobject.next() within the run() method of a Runnable in order to get back each document of a collection within a separate thread. As a result I get some documents duplicate, others are missing and randomly a NullPointerException occurs. I guess neither next() nor hasNext() are thread-safe here. |
| Comments |
| Comment by Jeffrey Yemin [ 07/Nov/12 ] |
|
Not all classes in the driver are thread safe, and DBCursor is one of them, by intention. Generally, iterators like DBCursor are not. We'll make sure to document that. |