[JAVA-168] WriteConcern constructor sets getlasterror incorrectly for w<1 Created: 28/Sep/10 Updated: 08/Feb/23 Resolved: 22/Nov/10 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dan Flye | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Creating a WriteConcern with a w value of 0 or -1 incorrectly sets getlasterror to 1 instead of 0. The callGetLastError method correctly returns true only if w > 0. It appears that this line in the constructor WriteConcern( int w , int wtimeout , boolean fsync): |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 22/Nov/10 ] |
|
This is working exactly as expected for me. |
| Comment by Dan Flye [ 28/Sep/10 ] |
|
The code in question is a junit test that attempts to exercise the various persistency layers in our app, with Morphia used for pojo/bson conversion. Chunk of pseudo code after wading through a bunch of classes is below. My scenario was to fire up the test with mongo running, stop the instance part way through, hope to observe a lack of errors, then restart the mongo instance. With original code, errors thrown each iteration; revised code, no errors thrown. // setup code: instantiate initial user object and insert in mongo catch (Exception e) { logger.info("defaultWriteConcern: " + defaultWriteConcern); }finally { db.requestDone(): }} |
| Comment by Eliot Horowitz (Inactive) [ 28/Sep/10 ] |
|
The value of the "getlasterror" field shouldn't matter at all. |
| Comment by Dan Flye [ 28/Sep/10 ] |
|
I'm going by what the Java API docs state: "WriteConcern control the write behavior for with various options, as well as exception raising on error conditions. w -1 = don't even report network errors My testing was done passing -1 for w; I was still seeing backtraces when my test mongo instance was off while attempting to call update... after changing the driver code as suggested above, the driver ignored network errors as I'd expected when w was -1. |
| Comment by Eliot Horowitz (Inactive) [ 28/Sep/10 ] |
|
w=0 and w=1 should be the same. |