Fix Reconnect error race condition (#15536)

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2023-09-01 16:16:16 -05:00 committed by GitHub
parent e254cb785c
commit b9a0e6fa14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 7 deletions

View File

@ -482,7 +482,6 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice
String error = null; String error = null;
if (openConnection()) { if (openConnection()) {
long prevUpdateTime = lastPollingUpdate;
// poll all zones on the amplifier to get current state // poll all zones on the amplifier to get current state
amp.getZoneIds().stream().limit(numZones).forEach((streamZoneId) -> { amp.getZoneIds().stream().limit(numZones).forEach((streamZoneId) -> {
try { try {
@ -505,11 +504,6 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice
logger.debug("Error sending Xantech periodic update commands: {}", e.getMessage()); logger.debug("Error sending Xantech periodic update commands: {}", e.getMessage());
} }
} }
// prevUpdateTime should have changed if a zone update was received
if (lastPollingUpdate == prevUpdateTime) {
error = "@text/offline.communication-error-polling";
}
} else { } else {
error = "@text/offline.communication-error-reconnection"; error = "@text/offline.communication-error-reconnection";
} }
@ -518,7 +512,6 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error);
} else { } else {
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
lastPollingUpdate = System.currentTimeMillis();
} }
} }
} }