Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338119 - JDK7: Opening an object results in CorruptObjectException
Summary: JDK7: Opening an object results in CorruptObjectException
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 0.10.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 0.12   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 11:37 EST by Ondrej Vrabec CLA
Modified: 2011-02-25 20:23 EST (History)
2 users (show)

See Also:


Attachments
proposed trivial patch (628 bytes, patch)
2011-02-24 11:40 EST, Ondrej Vrabec CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Vrabec CLA 2011-02-24 11:37:47 EST
Build Identifier: 

This manifests only on JDK7 (tested on JDK7 build 122 and later).
Trying to open an object with org.eclipse.jgit.storage.file.UnpackedObject.open() fails and results in a CorruptObjectException once jgit comes across a certain file.

As far as i can tell, the problem is in org.eclipse.jgit.storage.file.UnpackedObject.readSome(): the method reads from an input stream into a byte array, however forgets to increment an offset in the array during the second and ongoing pass of the loop, thus overwriting already read bytes.

There's no workaround, but the fix should be trivial.

Reproducible: Sometimes
Comment 1 Ondrej Vrabec CLA 2011-02-24 11:40:07 EST
Created attachment 189714 [details]
proposed trivial patch
Comment 2 Chris Aniszczyk CLA 2011-02-24 11:42:24 EST
cc'ng Shawn

Can you upload a patch to Gerrit?

http://wiki.eclipse.org/EGit/Contributor_Guide#Contributing_Patches
Comment 3 Shawn Pearce CLA 2011-02-25 20:23:28 EST
Fixed by commit 03f78fc3bc0c60e589c98d56830ffa5ba1eacd7e