eclipse-external-annotations-m2e-plugin icon indicating copy to clipboard operation
eclipse-external-annotations-m2e-plugin copied to clipboard

Handle ZipError: invalid END header

Open sylvainlaurent opened this issue 7 years ago • 2 comments

In one of my projects, the "update maven configuration" fails with what looks like a fatal error to eclipse ("a virtual machine error has occurred...").

Actually this is caused by the lastnpe m2e plugin (verson 1.0.0.201802020829) :

java.util.zip.ZipError: invalid END header (bad central directory offset)
	at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem.java:1605)
	at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1045)
	at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130)
	at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:117)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:326)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.read(ClasspathConfigurator.java:173)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.readLines(ClasspathConfigurator.java:132)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.getExternalAnnotationMapping(ClasspathConfigurator.java:116)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.lambda$3(ClasspathConfigurator.java:109)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.getExternalAnnotationMapping(ClasspathConfigurator.java:108)
	at org.lastnpe.m2e.core.configurator.ClasspathConfigurator.configureClasspath(ClasspathConfigurator.java:85)
	at org.eclipse.m2e.jdt.internal.DefaultClasspathManagerDelegate.populateClasspath(DefaultClasspathManagerDelegate.java:61)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:256)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:367)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:347)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:375)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.updateClasspath(BuildPathManager.java:194)
	at org.eclipse.m2e.jdt.internal.BuildPathManager.mavenProjectChanged(BuildPathManager.java:183)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.notifyProjectChangeListeners(ProjectRegistryManager.java:783)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.applyMutableProjectRegistry(ProjectRegistryManager.java:930)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:300)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:405)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:352)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1351)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:349)
	at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

I probably have a bad/corrupt jar file in my local maven repo, but the plugin should catch the exception.

sylvainlaurent avatar Feb 05 '18 21:02 sylvainlaurent

Just make sure it notifies the user about it as that case is probably something that a user would like to be aware of.

nfekete avatar Feb 06 '18 03:02 nfekete

I probably have a bad/corrupt jar file in my local maven repo

yeah, I remember hitting such errors in the past, not in our eclipse-external-annotations-m2e-plugin but from plain M2E or other (Maven-in-M2E) plugins... if I remember right, I think this could happen e.g. if we read JARs while they are just being refreshed.. or which are corrupt following an interupted download.

but the plugin should catch the exception.

Yes, if we just catch ZipError (and best even others, perhaps?), and log more details about which file it was reading, and then rethrow / log error that, you can see what you have to rm. (I'm pretty sure that a while ago I had raised a bug on eclipse.org for exactly that in M2E itself, or some such place...)

PS: If you want to raise a PR for this, I would merge it ASAP (so that we don't "self merge"; thanks for having merged my NPE one!)

vorburger avatar Feb 06 '18 19:02 vorburger