[JAVA-567] skip() throw exception with the source code version 2.7.2-141 Created: 14/May/12 Updated: 18/Jun/12 Resolved: 17/May/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | GridFS |
| Affects Version/s: | None |
| Fix Version/s: | 2.8.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | liugen | Assignee: | Daniel Gottlieb (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
windows7 |
||
| Issue Links: |
|
||||||||
| Description |
|
The java driver is compiled by myself, and source version is 2.7.2-141.
When I run this sample code, a exception was throwed with error message: Then I debug in skip() function:
In the line " _data = getChunk(_currentChunkIdx)", it throw exception |
| Comments |
| Comment by Jeffrey Yemin [ 18/Jun/12 ] | |||||||
|
Closing for 2.8.0 release. | |||||||
| Comment by Daniel Gottlieb (Inactive) [ 15/May/12 ] | |||||||
|
The new skip method defined in the patch https://github.com/mongodb/mongo-java-driver/commit/c3e1d1ea7cc98e3350c74b23810fdda7ebdc152a does exactly that. | |||||||
| Comment by liugen [ 15/May/12 ] | |||||||
|
Why not directly calculate the last chunk idx and the offset on that chunk like C# driver? // in mongo-csharp-driver / Driver / GridFS / MongoGridFSStream.cs switch (origin) { case SeekOrigin.Begin: _position = offset; break; case SeekOrigin.Current: _position += offset; break; case SeekOrigin.End: _position = _length + offset; break; default: throw new ArgumentException("origin"); }if (_length < _position) { SetLength(_position); } return _position; | |||||||
| Comment by Daniel Gottlieb (Inactive) [ 14/May/12 ] | |||||||
|
The code that will presumably fix your issue are in the following patches: | |||||||
| Comment by Jeffrey Yemin [ 14/May/12 ] | |||||||
|
This bug was introduced by changes in scope of | |||||||
| Comment by Daniel Gottlieb (Inactive) [ 14/May/12 ] | |||||||
|
I can't exactly reproduce your test case verbatim, but the skip function that you debugged got a facelift very recently on master for (seemingly) the same problem as you're seeing. You can try building the jar off master to see if that fixes your problem. Alternatively this problem only comes up when skip() is called before any read() methods are invoked. An (admittedly silly) workaround would be to read one byte then skip one less byte:
| |||||||
| Comment by Daniel Gottlieb (Inactive) [ 14/May/12 ] | |||||||
|
adding code tags for readability | |||||||
| Comment by Jeffrey Yemin [ 14/May/12 ] | |||||||
|
Can you check that this is a duplicate of the pull request you recently merged? I think it is. |