Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338119

Summary: JDK7: Opening an object results in CorruptObjectException
Product: [Technology] JGit Reporter: Ondrej Vrabec <ovrabec>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: caniszczyk, sop
Version: 0.10.0   
Target Milestone: 0.12   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
proposed trivial patch none

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