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'.
> MALFORMED

 * 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(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
...
Caused by: java.lang.IllegalArgumentException: MALFORMED
    at org.gradle.api.internal.tasks.testing.detection.JarFilePackageLister.listJarPackages(JarFilePackageLister.java:51)
    at org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager.addLibraryJar(ClassFileExtractionManager.java:55)
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.prepareClasspath(AbstractTestFrameworkDetector.java:96)
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.getSuperTestClassFile(AbstractTestFrameworkDetector.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitDetector.processTestClass(JUnitDetector.java:48)
    at org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector.processTestClass(AbstractTestFrameworkDetector.java:128)

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?