Bug 187365 - NPE trying to exclude part of a patch
Summary: NPE trying to exclude part of a patch
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC2   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-16 15:33 EDT by Olivier Thomann CLA
Modified: 2007-06-05 15:14 EDT (History)
0 users

See Also:
Olivier_Thomann: review+
Michael.Valenta: review+


Attachments
Patch (1.24 KB, patch)
2007-05-17 05:29 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylar/context/zip (20.80 KB, application/octet-stream)
2007-05-17 05:29 EDT, Tomasz Zarna CLA
no flags Details
Simple test (2.04 KB, patch)
2007-05-25 07:03 EDT, Tomasz Zarna CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-05-16 15:33:43 EDT
Using eclipse.buildId=I20070516-0800
java.version=1.6.0_02-ea
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Framework arguments:  -startup D:\eclipse\I0516\eclipse\plugins\org.eclipse.equinox.launcher_1.0.0.v20070515.jar -showlocation
Command-line arguments:  -os win32 -ws win32 -arch x86 -startup D:\eclipse\I0516\eclipse\plugins\org.eclipse.equinox.launcher_1.0.0.v20070515.jar -debug -consolelog -console -showlocation

I got this NPE trying to exclude part of a patch. Is this related to the old model ?

java.lang.NullPointerException
	at org.eclipse.compare.internal.patch.Patcher.setEnabledHunk(Patcher.java:581)
	at org.eclipse.compare.internal.patch.Patcher.setEnabledFile(Patcher.java:564)
	at org.eclipse.compare.internal.patch.Patcher.setEnabled(Patcher.java:549)
	at org.eclipse.compare.internal.patch.PatchDiffNode.setEnabled(PatchDiffNode.java:37)
	at org.eclipse.compare.internal.patch.PreviewPatchPage2$5.run(PreviewPatchPage2.java:193)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3673)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.eclipse.compare.patch.ApplyPatchOperation.openWizard(ApplyPatchOperation.java:154)
	at org.eclipse.compare.patch.ApplyPatchOperation.run(ApplyPatchOperation.java:198)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.compare.internal.patch.CompareWithPatchAction$1.run(CompareWithPatchAction.java:59)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3650)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3287)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2365)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2329)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2204)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:497)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1137)
Comment 1 Michael Valenta CLA 2007-05-16 15:39:39 EDT
Would it be possible for you to attach the patch that caused the problem?
Comment 2 Olivier Thomann CLA 2007-05-16 15:41:46 EDT
This is the patch attached to bug 187329. It is not a workspace patch.
Comment 3 Olivier Thomann CLA 2007-05-16 15:44:17 EDT
I wanted to apply only the test part and I could not exclude parts inside org.eclipse.jdt.core after I selected the compiler tests project as the location to apply the patch.
The part relative to org.eclipse.jdt.core was failing since it is not part of the compiler tests. But I could not exclude them without getting the NPE.
Comment 4 Michael Valenta CLA 2007-05-16 15:45:59 EDT
Tomasz, please investigate.
Comment 5 Tomasz Zarna CLA 2007-05-17 05:29:37 EDT
Created attachment 67634 [details]
Patch

This looks like an easy one. NPE was thrown due to fact that the patch provided by Olivier wasn't a workspace patch (it had no information about it's project). Two simple checks inside Patcher#setEnabledHunk should do the job. At least it works for me now :)
Comment 6 Tomasz Zarna CLA 2007-05-17 05:29:40 EDT
Created attachment 67635 [details]
mylar/context/zip
Comment 7 Michael Valenta CLA 2007-05-17 10:29:14 EDT
The fix looks safe enough to consider for RC2.
Comment 8 Michael Valenta CLA 2007-05-23 08:54:00 EDT
Olivier, could I get you to review the patch. It's fairly straight forward.
Comment 9 Olivier Thomann CLA 2007-05-23 09:31:11 EDT
+1. Patch is straight forward and help to exclude part of a patch when the patch is not a workspace patch
Comment 10 Michael Valenta CLA 2007-05-23 09:44:28 EDT
+1. Patch reviewed and released to HEAD.
Comment 11 Tomasz Zarna CLA 2007-05-25 07:03:51 EDT
Created attachment 68751 [details]
Simple test

I've been thinking about making the test more high-level (eg. start the test from parsing a non-workspace patch), but I hope the way it works now will also do the job.
Comment 12 Tomasz Zarna CLA 2007-05-25 07:05:47 EDT
Verified in I20070524-1800 and against the attached test.
Comment 13 Michael Valenta CLA 2007-05-25 09:15:08 EDT
Tests released.