Fix Reconnect error race condition (#15536)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
e254cb785c
commit
b9a0e6fa14
|
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue