Skip to content

Commit

Permalink
[hydrawise] Fix concurrent modification error
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan committed Jul 18, 2022
1 parent 7920dd6 commit 94fe116
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access
private static final String CLIENT_SECRET = "zn3CrjglwNV1";
private static final String CLIENT_ID = "hydrawise_app";
private static final String SCOPE = "all";
private final List<HydrawiseControllerListener> controllerListeners = new ArrayList<HydrawiseControllerListener>();
private final List<HydrawiseControllerListener> controllerListeners = Collections
.synchronizedList(new ArrayList<HydrawiseControllerListener>());
private final HydrawiseGraphQLClient apiClient;
private final OAuthClientService oAuthService;
private @Nullable ScheduledFuture<?> pollFuture;
Expand Down Expand Up @@ -197,9 +198,11 @@ private void poll(boolean retry) {
updateStatus(ThingStatus.ONLINE);
}
lastData = response.data.me;
controllerListeners.forEach(listener -> {
listener.onData(response.data.me.controllers);
});
synchronized (controllerListeners) {
controllerListeners.forEach(listener -> {
listener.onData(response.data.me.controllers);
});
}
} catch (HydrawiseConnectionException e) {
if (retry) {
logger.debug("Retrying failed poll", e);
Expand Down

0 comments on commit 94fe116

Please sign in to comment.