mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[hue] API v1: retry once on timeout for GET requests to the bridge (#16902)
Fix #16723 Signed-off-by: Laurent Garnier <lg.hc@free.fr> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
80c9e39ddb
commit
9ef18558ca
@ -1096,6 +1096,11 @@ public class HueBridge {
|
||||
|
||||
private HueResult doNetwork(String address, HttpMethod requestMethod, @Nullable String body)
|
||||
throws ConfigurationException, CommunicationException {
|
||||
return doNetwork(address, requestMethod, body, requestMethod == HttpMethod.GET);
|
||||
}
|
||||
|
||||
private HueResult doNetwork(String address, HttpMethod requestMethod, @Nullable String body, boolean retryOnTimeout)
|
||||
throws ConfigurationException, CommunicationException {
|
||||
logger.trace("Hue request: {} - URL = '{}'", requestMethod, address);
|
||||
try {
|
||||
final Request request = httpClient.newRequest(address).method(requestMethod).timeout(timeout,
|
||||
@ -1123,9 +1128,14 @@ public class HueBridge {
|
||||
e.getCause());
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
String message = e.getMessage();
|
||||
logger.debug("TimeoutException occurred during execution: {}", message, e);
|
||||
throw new CommunicationException(message == null ? TEXT_OFFLINE_COMMUNICATION_ERROR : message);
|
||||
if (retryOnTimeout) {
|
||||
logger.debug("TimeoutException occurred during execution, retry");
|
||||
return doNetwork(address, requestMethod, body, false);
|
||||
} else {
|
||||
String message = e.getMessage();
|
||||
logger.debug("TimeoutException occurred during execution: {}", message, e);
|
||||
throw new CommunicationException(message == null ? TEXT_OFFLINE_COMMUNICATION_ERROR : message);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
String message = e.getMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user