Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312728 - Java EE import fails if zip entries contain leading slashes
Summary: Java EE import fails if zip entries contain leading slashes
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Jason Sholl CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks: 313181
  Show dependency tree
 
Reported: 2010-05-12 18:04 EDT by Jason Sholl CLA
Modified: 2010-05-17 12:26 EDT (History)
2 users (show)

See Also:
jsholl: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
jsholl: pmc_approved? (naci.dai)
jsholl: pmc_approved? (deboer)
jsholl: pmc_approved? (neil.hauge)
jsholl: pmc_approved? (kaloyan)
ccc: review+


Attachments
patch (964 bytes, patch)
2010-05-12 18:07 EDT, Jason Sholl CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Sholl CLA 2010-05-12 18:04:57 EDT
Importing any EE artifact will fail if any of the zip entries contain leading slashes, e.g "/foo.txt" instead of "foo.txt".  It's not clear to me how the exmple ear archive was created, but it fails with an exception like the following:

java.lang.RuntimeException: /com/ibm/websphere/csi/ must be relative.
	at org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter.verifyRelative(Unknown Source)
	at org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter.createDirectory(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ZipFileArchiveLoadAdapterImpl.createFile(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ZipFileArchiveLoadAdapterImpl.getArchiveResources(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities$JavaEEWrappingLoadAdapter.getArchiveResources(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ArchiveImpl.getArchiveResources(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper.getSize(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.operations.EARComponentImportOperation.computeTotalWork(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation.execute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(Unknown Source)
	at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard$1CatchThrowableRunnableWithProgress.run(Unknown Source)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(Unknown Source)


The fix is very simple and safe which is to ensure the paths are relative by calling Path.makeRelative().  This method will return itself if it is already relative so will not have performance implications.
Comment 1 Jason Sholl CLA 2010-05-12 18:07:05 EDT
Created attachment 168286 [details]
patch
Comment 2 Carl Anderson CLA 2010-05-12 18:08:42 EDT
I approve of this fix.
Comment 3 Jason Sholl CLA 2010-05-12 18:31:47 EDT
    * Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

Import fails with exceptions

    * Is there a work-around? If so, why do you believe the work-around is insufficient? 

No

    * How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

UI

    * Give a brief technical overview. Who has reviewed this fix? 

See description

    * What is the risk associated with this fix? 

No
Comment 4 Jason Sholl CLA 2010-05-12 18:52:41 EDT
code checked into head for wtp 32 rc1