Community
Participate
Working Groups
In my program, I do a few actions on a repository object and dispose of it. I'd create a new repository object to do more later. This results in multiple DfsPackFile objects that represent the same file in the same repository existing throughout the process's life. In the DfsReader `copy` method, it loops through blocks in the file, on a condition `while (0 < need && position < length)`, with `length` taken from `file.length`, and where `file.length` is intended to be initialized when the `pin` call inside the loop loads the first block needed. However, when doing this for the second time on a fresh repository object DfsPackFile, sometimes the DfsBlockCache, which is a single shared instance, will contain the blocks needed. This results in no access to the file, which results in `file.length` not being populated--it remains -1. This causes the loop in `copy` to exit due to `position < length` not being satisfied, which causes `copy` to return without copying as many bytes as requested. For one thing, although "read" methods sometimes have this inconvenient behavior of sometimes reading fewer bytes than requested, such behavior is not documented in in `copy`. And more importantly, the `readFully` method of DfsPackFile only calls `copy` once, and throws EOFException if it comes up short.
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/173947
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/173947 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=a14455dfd7ac61e13f2ea8c7d789463efd8eeb72