# How can I avoid slow builds and even hangs when connecting to repositories?

**URL:** <https://discuss.gradle.org/t/how-can-i-avoid-slow-builds-and-even-hangs-when-connecting-to-repositories/19660>\
**Category:** Help/Discuss\
**Created:** [September 22, 2016, 12:28am UTC](https://discuss.gradle.org/t/how-can-i-avoid-slow-builds-and-even-hangs-when-connecting-to-repositories/19660 "2016-09-22T00:28:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinpa\_asg](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/justinpa_asg/32/3919_2.png) [@justinpa\_asg](https://discuss.gradle.org/u/justinpa_asg)\
**Post date:** [September 22, 2016, 12:28am UTC](https://discuss.gradle.org/t/how-can-i-avoid-slow-builds-and-even-hangs-when-connecting-to-repositories/19660/1 "2016-09-22T00:28:12Z")

</div>

It’s possible that earlier discussions [here](https://discuss.gradle.org/t/build-hangs-for-5-minutes-after-tests-finish-executing-m9/993), [here](https://discuss.gradle.org/t/deadlock-during-tests-when-using-log4j-to-log-to-the-stdout-in-multiple-threads/634), and [here](https://discuss.gradle.org/t/testng-parallel-test-execution-hangs-up/14107) are related, although I’m concerned about HttpClientHelper in particular. The root cause might be one or more bugs in JRE: [JDK-8049846](https://bugs.openjdk.java.net/browse/JDK-8049846) and [JDK-8075484](https://bugs.openjdk.java.net/browse/JDK-8075484). While these were fixed Sept-13-2016 (unreleased at time of this post), changes appear to be for non-Windows platforms and I’m observing problems on Windows. Some applications have developed workarounds, e.g. [Docker](https://github.com/docker-java/docker-java/issues/348).

[Here](http://pastebin.com/hN5jHT5s) is a thread call stack taken from Eclipse when debugging Gradle when it hangs (also seen by jstack). I suspended the thread to copy the call stack; otherwise it would still be running but hung. In short:

```
SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method] 
SocketInputStream.socketRead(FileDescriptor, byte[], int, int, int) line: 116         
SocketInputStream.read(byte[], int, int, int) line: 170     
...
HttpClientHelper.performHttpRequest(HttpRequestBase) line: 102

```

Even when Gradle doesn’t hang the majority of time is spent in HttpClientHelper. My company uses ArtifactoryOnline and our build times are very inconsistent. One colleague can reproduce the hang every time. I myself see the hang once every couple of weeks but do see frequent slowdowns. Here is a report from YourKit.

 ![](https://global.discourse-cdn.com/gradle/original/2X/a/a84b9998d7f9d7e9fea67dcea9c7837c799b3689.png)

So can Gradle developers implement a workaround ASAP or even investigate fixing the root cause? I have observed these hangs in Gradle 2.10 through 3.1.
