MALFORMED exception when looking for tests

Just got to the bottom of an annoying bug - looks like something that could be fixed with another line of exception handling.

“gradle build” (Gradle 2.2.1, Windows 7 6.1 64bit, JDK 1.8.0_40) fails with:

 FAILURE: Build failed with an exception.

 * What went wrong:
 Execution failed for task ':mso-apollo:test'.

 * Try:
  Run with --info or --debug option to get more log output.

  * Exception is:
 org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':mso-apollo:test'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(
Caused by: java.lang.IllegalArgumentException: MALFORMED
    at org.gradle.api.internal.tasks.testing.detection.JarFilePackageLister.listJarPackages(
    at org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager.addLibraryJar(
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.prepareClasspath(
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.getSuperTestClassFile(
    at org.gradle.api.internal.tasks.testing.junit.JUnitDetector.processTestClass(
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.processTestClass(

And after a long trawl through what could have caused it, it turned out to be unicode characters in one of the filenames of a resource in a dependency jar.

org.gradle.api.artifacts.indexing. JarFilePackageLister catches the IOException, but doesn’t catch RuntimeExceptions that crawl out from the slightly flakey zip handling APIs. The zip entry decode blows up on the unicode, and throws the IllegalArgumentException which kills the entire build.

Let me know if you need any more info - hopefully an easy fix by adding another catch block - might be worth logging the issue any carrying on rather than stopping the entire build?

Isn’t this really fatal though? Isn’t the JAR unusable if this exception occurs?

Why does this exception actually occur though? That is, why can’t it handle Unicode?