[MSHARED-87] ZipException throw by SDK's JarFile constructor may lack file name.
authorOlivier Lamy <olamy@apache.org>
Fri, 4 Sep 2009 21:20:53 +0000 (21:20 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 4 Sep 2009 21:20:53 +0000 (21:20 +0000)
Submitted by Jerome Lacoste.

git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@811555 13f79535-47bb-0310-9956-ffa450edef68

src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java

index 3d27894..a063ee0 100644 (file)
@@ -32,6 +32,7 @@ import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.zip.ZipException;
 
 /**
  * Open a JAR file to be analyzed. Note that once created, the {@link #closeQuietly()} method should be called to
@@ -99,7 +100,16 @@ public class JarAnalyzer
     public JarAnalyzer( File file )
         throws IOException
     {
-        this.jarFile = new JarFile( file );
+        try
+        {
+            this.jarFile = new JarFile( file );
+        }
+        catch ( ZipException e )
+        {
+            ZipException ioe = new ZipException( "Failed to open file " + file + " : " + e.getMessage() );
+            ioe.initCause( e );
+            throw ioe;
+        }
 
         // Obtain entries list.
         List entries = Collections.list( jarFile.entries() );