Skip to content

Commit

Permalink
ignore SocketTimeoutException on background status refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Michels <markus7017@gmail.com>
  • Loading branch information
markus7017 committed Apr 29, 2020
1 parent c69d59c commit 15f2e78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class GreeBindingConstants {
* This is particularly important when scanning for devices because this will effectively
* be the amount of time spent scanning.
*/
public static final int DATAGRAM_SOCKET_TIMEOUT = 5000;
public static final int DATAGRAM_SOCKET_TIMEOUT = 3000;
public static final int MINIMUM_REFRESH_TIME_MS = 1000;
public static final int DEFAULT_REFRESH_TIME_MS = 1000;

public static final int DISCOVERY_TIMEOUT_MS = 7000;
public static final int DISCOVERY_TIMEOUT_MS = 5000;
public static final int MAX_SCAN_CYCLES = 3;

public static final int DIGITS_TEMP = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.gree.internal;

import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.text.MessageFormat;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -79,8 +80,9 @@ public boolean isApiException() {

public boolean isTimeout() {
Class<?> extype = !isEmpty() ? getCauseClass() : null;
return (extype != null) && ((extype == TimeoutException.class) || (extype == ExecutionException.class)
|| (extype == InterruptedException.class) || getMessage().toLowerCase().contains("timeout"));
return (extype != null) && ((extype == SocketTimeoutException.class) || (extype == TimeoutException.class)
|| (extype == ExecutionException.class) || (extype == InterruptedException.class)
|| getMessage().toLowerCase().contains("timeout"));
}

public boolean isUnknownHost() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ public void run() {
publishChannelIfLinked(channel.getUID());
}

} catch (GreeException | RuntimeException e) {
} catch (GreeException e) {
if (!e.isTimeout()) {
logger.debug("Unable to perform auto-update: {}", e.toString());
}
} catch (RuntimeException e) {
logger.debug("Unable to perform auto-update", e);
}
}
Expand Down

0 comments on commit 15f2e78

Please sign in to comment.