Gradle wrapper download fails via http [new]

Suddenly all the builds which are using http to download gradlew are failing.

 ./gradlew tasks
Unzipping /Users/sandeshw/.gradle/wrapper/dists/gradle-2.14.1-bin/ev4hc1s4g1oc9yuae0b81rdza/ to /Users/sandeshw/.gradle/wrapper/dists/gradle-2.14.1-bin/ev4hc1s4g1oc9yuae0b81rdza
Exception in thread "main" zip file is empty
        at java.base/$Source.zerror(
        at java.base/$Source.findEND(
        at java.base/$Source.initCEN(
        at java.base/$Source.<init>(
        at java.base/$Source.get(
        at java.base/<init>(
        at java.base/<init>(
        at java.base/<init>(
        at org.gradle.wrapper.Install.unzip(
        at org.gradle.wrapper.Install.access$600(
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(
        at org.gradle.wrapper.Install.createDist(
        at org.gradle.wrapper.WrapperExecutor.execute(
        at org.gradle.wrapper.GradleWrapperMain.main( configuration is:

It works if I change to use https:

We have 100s of the project with Http setting.
Do we need to change every project to use https instead of Http?

Seems familiar with the old post:

Yes, I believe you will have to do that for all your projects. You can read about the reasoning for this in the announcement here.

According to that, the default has been https since Gradle 1.2, and you are on 2.14.1. So it’s a bit weird that your wrappers are configured with plain http to begin with.

While annoying to change for that many projects, it is important that you do it from a security perspective. Right now you are vulnerable to a man-in-the-middle attack, and you should feel good about doing something about it.

1 Like

Hi @sandeshwani,

I’m sorry to hear that this decommission is causing issues for you. It sounds like you may also potentially hitting this JDK bug from Java 1.3 where a URL Connection would not follow a redirect that had a protocol switch (ie. HTTP -> HTTPS). For the short term, if you can update to a JDK version that does not have that bug, this may fix your problem in the short term, however, in the longer term, you will have to migrate these builds to use HTTPS.

Thanks for the response. We are using JDK 1.8+ in every project.