If an IOException is thrown during the execution of an HttpCommand retry only 
if the HTTP method doesn't have side effects (i.e. GET, HEAD). Otherwise the 
retry could cause unwanted side effects (i.e. creating and leaking multiple new 
nodes).

In my particular case Softlayer was timing out with the response and the 
retries eventually caused 6 machines to be created, but leaked, leaving them 
online and billing by the hour.

```
Caused by: java.net.SocketTimeoutException: Read timed out
    at sun.reflect.GeneratedConstructorAccessor111.newInstance(Unknown Source)
    at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:58)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:542)
    at 
sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1687)
    at 
sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1685)
    at java.security.AccessController.doPrivileged(AccessController.java:333)
    at 
sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1683)
    at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1256)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    at com.ibm.net.ssl.www2.protocol.https.b.getResponseCode(b.java:63)
    at 
org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.invoke(JavaUrlHttpCommandExecutorService.java:105)
    at 
org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.invoke(JavaUrlHttpCommandExecutorService.java:66)
    at 
org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:89)
    at 
org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
    at 
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
    at 
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
    at 
org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
    at 
com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
    at com.sun.proxy.$Proxy134.createVirtualGuest(Unknown Source)
    at 
org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter.createNodeWithGroupEncodedIntoName(SoftLayerComputeServiceAdapter.java:208)
    at 
org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.createNodeWithGroupEncodedIntoName(AdaptingComputeServiceStrategies.java:195)
    at 
org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet$AddNode.call(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:79)
    at 
org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet$AddNode.call(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:63)
    ... 4 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:164)
    at java.net.SocketInputStream.read(SocketInputStream.java:134)
    at com.ibm.jsse2.a.a(a.java:244)
    at com.ibm.jsse2.a.a(a.java:35)
    at com.ibm.jsse2.qc.a(qc.java:189)
    at com.ibm.jsse2.qc.a(qc.java:513)
    at com.ibm.jsse2.e.read(e.java:15)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:247)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:287)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:346)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:717)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:663)
    at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1335)
    at com.ibm.net.ssl.www2.protocol.https.b.getInputStream(b.java:9)
    at 
org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.invoke(JavaUrlHttpCommandExecutorService.java:97)
    ... 16 more

```
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds/pull/744

-- Commit Summary --

  * Don't retry unsafe HTTP methods in case of an IOException

-- File Changes --

    M 
core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java 
(16)
    M 
core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java
 (59)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/744.patch
https://github.com/jclouds/jclouds/pull/744.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/744

Reply via email to