Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 508980

Summary: Error opening zip file in JDT
Product: [Eclipse Project] JDT Reporter: Ulrich Hobelmann <ulrich.hobelmann>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, stephan.herrmann
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Ulrich Hobelmann CLA 2016-12-09 07:29:39 EST
Happens constantly when I hover a class or during certain code completion triggers. Extremely annoying, as the error view keeps popping up.

I tried deleting the whole versions in my maven repo, but the error still occurs. The jars also look fine, but it's also hard to say if I'm looking at the right jar. It might be some other file it's stumbling over, as it doesn't say which one it's trying to read.

What steps will reproduce the problem?
1. Hover over a class from the JIRA api. (like jira-api-7.0.5.jar)


-- Error Details --
Date: Fri Dec 09 13:24:15 CET 2016
Message: Internal Error
Severity: Error
Product: Eclipse 4.6.1.20161007-1200 (org.eclipse.epp.package.java.product)
Plugin: org.eclipse.jdt.ui
Exception Stack Trace:
Java Model Exception: java.util.zip.ZipException: error in opening zip file
	at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:928)
	at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1039)
	at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:997)
	at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:538)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:717)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:635)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:627)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:164)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:86)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)
Caused by: java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:219)
	at java.util.zip.ZipFile.<init>(ZipFile.java:149)
	at java.util.jar.JarFile.<init>(JarFile.java:166)
	at java.util.jar.JarFile.<init>(JarFile.java:103)
	at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
	at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
	at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
	at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
	at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:862)
	... 10 more
Caused by: java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:219)
	at java.util.zip.ZipFile.<init>(ZipFile.java:149)
	at java.util.jar.JarFile.<init>(JarFile.java:166)
	at java.util.jar.JarFile.<init>(JarFile.java:103)
	at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
	at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
	at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
	at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
	at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:862)
	at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1039)
	at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:997)
	at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:538)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:717)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:635)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:627)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:164)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:86)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)


-- Error Details --
Date: Fri Dec 09 13:24:15 CET 2016
Message: error in opening zip file
Severity: Error
Product: Eclipse 4.6.1.20161007-1200 (org.eclipse.epp.package.java.product)
Plugin: org.eclipse.jdt.core
Exception Stack Trace:
java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:219)
	at java.util.zip.ZipFile.<init>(ZipFile.java:149)
	at java.util.jar.JarFile.<init>(JarFile.java:166)
	at java.util.jar.JarFile.<init>(JarFile.java:103)
	at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
	at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
	at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
	at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
	at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:862)
	at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1039)
	at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:997)
	at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:538)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:717)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:635)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:627)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:164)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:86)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)
Comment 1 Stephan Herrmann CLA 2016-12-10 09:47:52 EST
This exception definitely lacks relevant information.

URLConnection.getInputStream() doesn't seem to provide this information when somewhere inside a ZipException is thrown.

JavaElement.getURLContents() is in a good position to fill in this information (e.g., inside an addition specific "catch (ZipException e)"), but I'm not 100% sure which is the best strategy for combining the exception + additional message parts into a JavaModelStatus or JavaModelException. Perhaps the catch block from MalformedURLException gives a good example:
   throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC, this))

Maybe, this form should be preferred for several of the caught-wrapped-rethrown exceptions?

@Jay, @Manoj, what's your say?
Comment 2 Jay Arthanareeswaran CLA 2016-12-12 05:25:23 EST
(In reply to Stephan Herrmann from comment #1)
> JavaElement.getURLContents() is in a good position to fill in this
> information (e.g., inside an addition specific "catch (ZipException e)"),
> but I'm not 100% sure which is the best strategy for combining the exception
> + additional message parts into a JavaModelStatus or JavaModelException.
> Perhaps the catch block from MalformedURLException gives a good example:
>    throw new JavaModelException(new
> JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC,
> this))

Not sure I understand your point. This example only captures the current element and not the URL we are trying to open.
Comment 3 Stephan Herrmann CLA 2016-12-12 10:17:04 EST
(In reply to Jay Arthanareeswaran from comment #2)
> (In reply to Stephan Herrmann from comment #1)
> > JavaElement.getURLContents() is in a good position to fill in this
> > information (e.g., inside an addition specific "catch (ZipException e)"),
> > but I'm not 100% sure which is the best strategy for combining the exception
> > + additional message parts into a JavaModelStatus or JavaModelException.
> > Perhaps the catch block from MalformedURLException gives a good example:
> >    throw new JavaModelException(new
> > JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC,
> > this))
> 
> Not sure I understand your point. This example only captures the current
> element and not the URL we are trying to open.

Your're right, but that would already be way better than what we have today: no information at all :-/

OTOH, does JavaModelStatus support custom exception details?
Comment 4 Jay Arthanareeswaran CLA 2016-12-13 04:03:52 EST
(In reply to Stephan Herrmann from comment #3)
> Your're right, but that would already be way better than what we have today:
> no information at all :-/
> 
> OTOH, does JavaModelStatus support custom exception details?

I see that creating a JMException with an exception does propagate the exception to the newly created JavaModelStatus. Clients are free to make use of it via 

org.eclipse.core.runtime.Status.getException().

That is what the currently effective catch block is doing, but clearly we are not getting the right message in the log.
Comment 5 Jay Arthanareeswaran CLA 2016-12-13 04:11:17 EST
For the records, a similar issue was reported in apt (bug 474770).

If the ZipException doesn't contain the troublesome file name, perhaps we can simply log the error before creating the JME?
Comment 6 Eclipse Genie CLA 2019-05-18 18:52:45 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.