Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322732 - NPE when opening compare editor from first changeset in synchronize view
Summary: NPE when opening compare editor from first changeset in synchronize view
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: 0.9.0-M2   Edit
Assignee: Dariusz Luksza CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 322498 322920 (view as bug list)
Depends on: 322935
Blocks:
  Show dependency tree
 
Reported: 2010-08-15 18:57 EDT by Matthias Sohn CLA
Modified: 2010-08-20 15:59 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Sohn CLA 2010-08-15 18:57:37 EDT
egit version: 562b88498
jgit version: 8d761febc

eclipse.buildId=I20100608-0911
java.version=1.6.0_20
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.platform.ide
Command-line arguments:  -product org.eclipse.platform.ide -data /Users/d029788/Documents/workspace/egit/../runtime-New_configuration -dev file:/Users/d029788/Documents/workspace/egit/.metadata/.plugins/org.eclipse.pde.core/EGit/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog

- clone jgit
- change one jgit source file and commit the change
- Team > Synchronize
- the changeset containing this change is shown properly
- drill down to file which has been changed in Synchronize view
- double click on the changed file in Synchronize view
- NPE is thrown
- do another change and repeat the sequence on this change -> no NPE is thrown

Error
Mon Aug 16 00:43:00 CEST 2010
An internal error occurred during: "Initializing Compare Editor".

java.lang.NullPointerException
	at org.eclipse.jgit.util.RawParseUtils.author(RawParseUtils.java:549)
	at org.eclipse.jgit.revwalk.RevCommit.getAuthorIdent(RevCommit.java:303)
	at org.eclipse.egit.core.internal.storage.CommitFileRevision.<init>(CommitFileRevision.java:59)
	at org.eclipse.egit.core.internal.storage.GitFileRevision.inCommit(GitFileRevision.java:50)
	at org.eclipse.egit.ui.internal.CompareUtils.getFileRevision(CompareUtils.java:110)
	at org.eclipse.egit.ui.internal.CompareUtils.getFileRevisionTypedElement(CompareUtils.java:73)
	at org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob.getRight(GitModelBlob.java:114)
	at org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob.prepareInput(GitModelBlob.java:141)
	at org.eclipse.team.internal.ui.mapping.ModelCompareEditorInput.prepareCompareInput(ModelCompareEditorInput.java:121)
	at org.eclipse.team.ui.synchronize.SaveableCompareEditorInput.prepareInput(SaveableCompareEditorInput.java:235)
	at org.eclipse.compare.CompareEditorInput.run(CompareEditorInput.java:483)
	at org.eclipse.compare.internal.CompareUIPlugin.prepareInput(CompareUIPlugin.java:548)
	at org.eclipse.compare.internal.CompareEditor$2.run(CompareEditor.java:349)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Dariusz Luksza CLA 2010-08-17 03:32:01 EDT
I've investigate it and it appears that this NPE occurs for all files that are associated with oldest commit that is included in change set.
Comment 2 Chris Aniszczyk CLA 2010-08-17 11:58:47 EDT
*** Bug 322920 has been marked as a duplicate of this bug. ***
Comment 3 Dariusz Luksza CLA 2010-08-17 12:33:12 EDT
From my point of view this look like a bug in JGit. For some strange reasons JGit lost some data in RevCommit object. From my investigations appears that sometime:
revCommit.getParrent(0).getAuthorIdent()
throws NPE but calling:
revCommit.getParrent(0).getId()
on same object return commit SHA-1

Quick fix for this seems to be re-parsing revCommit object, so I've add this to GitCommiModel constructor. Check does all baseCommit's has author indent and it appears to be working ... but while calling Compare View NPE still occur. Even that all baseCommit's was re-parsed in GitModelObject constructor.

Finally, the true quick fix for this would be replacing simple getBaseCommit() in GitModelBlob.getRight() with RevWalk.parseCommit(getBaseCommit()). With this approach NPE doesn't occur any more but this is rather workaround then true fix.
Comment 4 Chris Aniszczyk CLA 2010-08-17 12:35:03 EDT
(In reply to comment #3)
> From my point of view this look like a bug in JGit. For some strange reasons
> JGit lost some data in RevCommit object. From my investigations appears that
> sometime:
> revCommit.getParrent(0).getAuthorIdent()
> throws NPE but calling:
> revCommit.getParrent(0).getId()
> on same object return commit SHA-1
> 
> Quick fix for this seems to be re-parsing revCommit object, so I've add this to
> GitCommiModel constructor. Check does all baseCommit's has author indent and it
> appears to be working ... but while calling Compare View NPE still occur. Even
> that all baseCommit's was re-parsed in GitModelObject constructor.
> 
> Finally, the true quick fix for this would be replacing simple getBaseCommit()
> in GitModelBlob.getRight() with RevWalk.parseCommit(getBaseCommit()). With this
> approach NPE doesn't occur any more but this is rather workaround then true
> fix.

Send an email to jgit-dev and file a bug against JGit.
Comment 5 Dariusz Luksza CLA 2010-08-19 10:29:11 EDT
This patch should fix this:

http://egit.eclipse.org/r/1339
Comment 6 Chris Aniszczyk CLA 2010-08-19 10:35:58 EDT
Fixed with ff88637c69af6e114c3d8c722681f655943dfe23

Thanks Dariusz!
Comment 7 Remy Suen CLA 2010-08-20 15:59:36 EDT
*** Bug 322498 has been marked as a duplicate of this bug. ***