Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 307209 - ZipException missing filename
Summary: ZipException missing filename
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-26 12:04 EDT by Lazar Kirchev CLA
Modified: 2010-03-31 11:23 EDT (History)
0 users

See Also:


Attachments
Sample bundle to reproduce the problem. (1.29 KB, application/java-archive)
2010-03-26 12:05 EDT, Lazar Kirchev CLA
no flags Details
Source code of the sample bundle. (2.90 KB, application/zip)
2010-03-26 12:10 EDT, Lazar Kirchev CLA
no flags Details
Patch which fixes the message of the ZipException in SecureAction (2.04 KB, patch)
2010-03-26 12:14 EDT, Lazar Kirchev CLA
tjwatson: iplog+
Details | Diff
Updatd patch (2.08 KB, patch)
2010-03-30 14:44 EDT, Thomas Watson CLA
no flags Details | Diff
Proposed patch, diferentiating ZipExceptions from other IOExceptions (2.31 KB, patch)
2010-03-31 06:28 EDT, Lazar Kirchev CLA
tjwatson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lazar Kirchev CLA 2010-03-26 12:04:26 EDT
Build Identifier: 3.5

When trying to open a zip file (e.g., when loading resources) which cannot be opened, the ZipException which is thrown does not contain the name of the file. 

Reproducible: Always

Steps to Reproduce:
A sample bundle which reproduces the problem is attached.

1. Install the bundle
2. Start the bundle
3. Check the log file to see that the exception does not contain the name of the file
Comment 1 Lazar Kirchev CLA 2010-03-26 12:05:48 EDT
Created attachment 163093 [details]
Sample bundle to reproduce the problem.
Comment 2 Lazar Kirchev CLA 2010-03-26 12:10:39 EDT
Created attachment 163095 [details]
Source code of the sample bundle.
Comment 3 Lazar Kirchev CLA 2010-03-26 12:14:51 EDT
Created attachment 163096 [details]
Patch which fixes the message of the ZipException in SecureAction

The patch adds to the message of the ZipException the name of the file, which cannot be opened.
Comment 4 Thomas Watson CLA 2010-03-30 14:44:25 EDT
Created attachment 163438 [details]
Updatd patch

Thanks for the patch.  Here is an updated patch that catches all IOExceptions.  Seems like we would want the file name in all IOException cases, not just for ZipExceptions.  I also used the File.getPath method instead to give a path to the file that could not be opened.
Comment 5 Thomas Watson CLA 2010-03-30 14:45:32 EDT
Updated patch released.
Comment 6 Thomas Watson CLA 2010-03-30 14:46:12 EDT
Comment on attachment 163096 [details]
Patch which fixes the message of the ZipException in SecureAction

Thanks for the patch  Lazar!
Comment 7 Lazar Kirchev CLA 2010-03-31 02:22:17 EDT
Thanks for the timely response and the update of the patch!
Comment 8 Lazar Kirchev CLA 2010-03-31 06:26:20 EDT
My only concern regarding the updated patch is that it wraps in ZipExceptions all IOExceptions - if, for example, a FileNotFoundException is thrown, it will be wrapped in ZipException. 
Probably ZipExceptions and the other IOExceptions may be processed separately. In both cases the name of the problematic file will be added to the exception, and the difference will be only in the type of the exception thrown. 
In this way, if a caller is interested only in real ZipExceptions, he will not receive other exceptions, disguised as ZipExceptions.
Comment 9 Lazar Kirchev CLA 2010-03-31 06:28:34 EDT
Created attachment 163514 [details]
Proposed patch, diferentiating ZipExceptions from other IOExceptions

Here I propose a small change regarding my concern.
Comment 10 Thomas Watson CLA 2010-03-31 10:16:11 EDT
Thanks I agree.  I did not mean to wrap the exception in a ZipException.  Good catch!
Comment 11 Thomas Watson CLA 2010-03-31 11:22:49 EDT
Comment on attachment 163514 [details]
Proposed patch, diferentiating ZipExceptions from other IOExceptions

Thanks for the patch!
Comment 12 Thomas Watson CLA 2010-03-31 11:23:29 EDT
patch released.