Bug 206460 - manifestFolderRenameParticipant causes NPE
Summary: manifestFolderRenameParticipant causes NPE
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Joern Dinkla CLA
QA Contact: Darin Wright CLA
URL:
Whiteboard:
Keywords: bugday, contributed
: 220734 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-16 09:35 EDT by Tillmann Seidel CLA
Modified: 2008-03-07 18:08 EST (History)
5 users (show)

See Also:
baumanbr: review+


Attachments
Patch (2.11 KB, patch)
2007-10-20 03:37 EDT, Joern Dinkla CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tillmann Seidel CLA 2007-10-16 09:35:10 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. Create a Java project "test" and switch to the Java perspective
2. Create empty file META-INF/MANIFEST.MF
3. Execute "Refactor->Rename" on the project with new name "test2"
4. Observe an error pop-up and an entry in the PDE error log


More information:
This happens if you work with Java projects which are no plug-in projects but have a manifest file located in META-INF/MANIFEST.MF (which is not a bundle manifest). 

As the stack trace reveals:

java.lang.NullPointerException
at org.eclipse.pde.internal.ui.refactoring.ContainerRenameParticipant.createManifestChange(ContainerRenameParticipant.java:88)
at org.eclipse.pde.internal.ui.refactoring.ContainerRenameParticipant.createChange(ContainerRenameParticipant.java:68)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.createChange(ProcessorBasedRefactoring.java:250)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

the problem lies in the ContainerRenameParticipant. It assumes that a file named META-INF/MANIFEST.MF is a OSGi bundle manifest, tries to read the BundleSymbolicNameHeader and does not check whether it exists.

It should do a null check on the BundleSymbolicNameHeader here.
Comment 1 Joern Dinkla CLA 2007-10-20 03:37:48 EDT
Created attachment 80816 [details]
Patch
Comment 2 Joern Dinkla CLA 2007-10-20 03:39:25 EDT
I inserted an "if ( header != null )" statement and reorganized the code a little bit.

 
Comment 3 Brian Bauman CLA 2007-10-22 11:16:46 EDT
Thanks Joern for the patch.  We appreciate the extra help!

Your patch completely resolves the NPE.  The one thing I slightly modified was to include the rest of the try/catch block in the if (BundleSymbolicHeader != null) block.  The reason is, if the Manifest does not have the header, we should exit right away.  If we don't, when the user clicks the preview button in the wizard, we show an empty change.

Thanks again for your contributions.
Comment 4 Brian Bauman CLA 2007-10-30 15:17:46 EDT
Darin, can you verify this bug when you get a chance.
Comment 5 Benjamin Cabé CLA 2008-03-07 18:08:07 EST
*** Bug 220734 has been marked as a duplicate of this bug. ***