Skip to content

Commit d84d955

Browse files
committed
GROOVY-12005: flaky CDN causes some jars to appear corrupt
1 parent d77adc2 commit d84d955

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/main/groovy/groovy/grape/GrapeUtil.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner
2727
import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl
2828

2929
import java.util.jar.JarFile
30+
import java.util.logging.Level
31+
import java.util.logging.Logger
3032
import java.util.zip.ZipEntry
3133
import java.util.zip.ZipException
3234
import java.util.zip.ZipFile
@@ -42,6 +44,7 @@ class GrapeUtil {
4244
private static final String METAINF_PREFIX = 'META-INF/services/'
4345
private static final String RUNNER_PROVIDER_CONFIG = GroovyRunner.name
4446
private static final boolean DEBUG_GRAPE = Boolean.getBoolean('groovy.grape.debug')
47+
private static final Logger LOGGER = Logger.getLogger(GrapeUtil.name)
4548

4649
/**
4750
* Adds a URI to a classloader's classpath via reflection.
@@ -90,7 +93,11 @@ class GrapeUtil {
9093
}
9194
}
9295
} catch (ZipException e) {
93-
throw new RuntimeException("Grape could not load jar '$file'", e)
96+
// Corrupt JAR (e.g. truncated download from a CDN 429/partial response): skip
97+
// extension-method scanning rather than aborting the whole @Grab. If the JAR is
98+
// actually used, the corruption will surface where the bytes are needed; meanwhile
99+
// other JARs in this grab continue to register their extensions normally.
100+
LOGGER.log(Level.WARNING, "Grape could not process jar '${file}' for extension methods", e)
94101
}
95102
}
96103
}

0 commit comments

Comments
 (0)