# Class HttpBackOffIOExceptionHandler (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.HttpBackOffIOExceptionHandler)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.HttpBackOffIOExceptionHandler)

    public class HttpBackOffIOExceptionHandler implements HttpIOExceptionHandler

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta)   

[HttpIOExceptionHandler](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpIOExceptionHandler) implementation with [BackOff](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff).

It is designed to work with only one [HttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequest) at a time. As a result you MUST
create a new instance of [HttpBackOffIOExceptionHandler](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpBackOffIOExceptionHandler) with a new instance of [BackOff](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff) for each instance of [HttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequest).

Sample usage:

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff());

Note: Implementation doesn't call [BackOff#reset](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff#com_google_api_client_util_BackOff_reset_) at all, since it expects a new [BackOff](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff) instance.

Implementation is not thread-safe

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> HttpBackOffIOExceptionHandler

## Implements

[HttpIOExceptionHandler](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpIOExceptionHandler)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### HttpBackOffIOExceptionHandler(BackOff backOff)

    public HttpBackOffIOExceptionHandler(BackOff backOff)

Constructs a new instance from a [BackOff](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `backOff` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff` back-off policy |

## Methods

### getBackOff()

    public final BackOff getBackOff()

Returns the back-off.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff` |   |

### getSleeper()

    public final Sleeper getSleeper()

Returns the sleeper.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Sleeper` |   |

### handleIOException(HttpRequest request, boolean supportsRetry)

    public boolean handleIOException(HttpRequest request, boolean supportsRetry)

Invoked when an [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html) is thrown during an HTTP request.

There is a simple rule that one must follow: If you modify the request object or modify its
execute interceptors in a way that should resolve the error, you must return `true` to
issue a retry.

Handles the request with [BackOff](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.BackOff). That means that if back-off is required a call to
[Sleeper#sleep(long)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Sleeper#com_google_api_client_util_Sleeper_sleep_long_) will be made.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequest` |
| `supportsRetry` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### setSleeper(Sleeper sleeper)

    public HttpBackOffIOExceptionHandler setSleeper(Sleeper sleeper)

Sets the sleeper.

The default value is [Sleeper#DEFAULT](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Sleeper#com_google_api_client_util_Sleeper_DEFAULT).

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `sleeper` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Sleeper` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpBackOffIOExceptionHandler` |   |