#353 Problems with JAR support

Ryan Baker

I took the path of creating a JAR file with the checkstyle.xml file inside it. This is stored in a Maven repository and we have a "corporate" pom which points to the currently correct version.

Initially this all worked well, and continues to work well with all tools except eclipse-cs. The first problem was a doozy. If the file gets over 8k (plus or minus some "whitespace"), then eclipse-cs starts to give an error.

To give you a little better info on what's influencing eclipse-cs, there is a Maven-Eclipse connector for Checkstyle, which using the information in the Maven POM sets the "Check Configuration" Location to something like : jar:file:/C:/.m2/repository/groupId/checkstyle-rules/1.0.0/checkstyle-rules-1.0.0.jar!/checkstyle.xml

The error is the following error:

net.sf.eclipsecs.core.util.CheckstylePluginException: Unexpected end of ZLIB input stream
    at net.sf.eclipsecs.core.util.CheckstylePluginException.rethrow(CheckstylePluginException.java:66)
    at net.sf.eclipsecs.core.util.CheckstylePluginException.rethrow(CheckstylePluginException.java:77)
    at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType.getCheckstyleConfiguration(RemoteConfigurationType.java:160)
    at net.sf.eclipsecs.core.config.CheckConfiguration.getCheckstyleConfiguration(CheckConfiguration.java:202)
    at net.sf.eclipsecs.core.builder.CheckerFactory.getCacheKey(CheckerFactory.java:222)
    at net.sf.eclipsecs.core.builder.CheckerFactory.createChecker(CheckerFactory.java:122)
    at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:142)
    at net.sf.eclipsecs.core.builder.CheckstyleBuilder.handleBuildSelection(CheckstyleBuilder.java:288)
    at net.sf.eclipsecs.core.builder.CheckstyleBuilder.build(CheckstyleBuilder.java:169)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:411)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:996)
    at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:217)
    at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType.getBytesFromURLConnection(RemoteConfigurationType.java:338)
    at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType.getCheckstyleConfiguration(RemoteConfigurationType.java:112)

This is in itself a problem, but there is a further difficulty. The next issue is using a suppressions.xml file. This is a problem which probably has multiple possible solutions, not all needing to be inside eclipse-cs. It would however be oh so nice if eclipse-cs recogonized the location of the checkstyle.xml was a jar and had that in the classpath to find related files like suppressions.xml that might be referenced from checkstyle.xml.


  • Lars Koedderitzsch

    Hi Ryan, I have no idea about the IO error on the jar resource URL. As you see in the stack trace no custom eclipse-cs code is involved here - just a URLConnection is being created from the resource URL and read from it.
    To add on top what the me2 connector does there (generating that jar resource URL) is not exactly supported by the plugin, the remote configuration option was foremost meant to be used for external remote configuration sources, e.g. a configuration file in a artifact repository (Nexus, Artifactory) or a intranet webserver.

    The second problem you mention cannot be solved in eclipse-cs alone, since certain limitations of the core Checkstyle engine apply. For instance it wouldn't be possible to load such an external suppression file from the project classpath - since Checkstyle doesn't have an option to pass the appropriate classloader for this.

    In general the handling for those addon files in Checkstyle is not unified and other occurrences (e.g. Header check, ImportControl) are even more limited than the SuppressionFilter implementation.

    Personally I'd advise to reconfigure the Maven Checkstyle plugin and the eclipse-cs plugin to load your configuration from a http URL, e.g. mentioned artifact repository.
    I'd expect that to work better along what you require, even with the possibility to co-locate a suppressions file.


  • Lars Koedderitzsch

    • status: open --> closed
    • assigned_to: Lars Koedderitzsch

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks