Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[knx] Handle exceptions during initial read #12520

Merged
merged 1 commit into from
Apr 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.time.Duration;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -291,6 +292,8 @@ private void readNextQueuedDatapoint() {
logger.trace("Sending a Group Read Request telegram for {}", datapoint.getDatapoint().getMainAddress());
processCommunicator.read(datapoint.getDatapoint());
} catch (KNXException e) {
// Note: KnxException does not cover KnxRuntimeException and subclasses KnxSecureException,
// KnxIllegArgumentException
if (datapoint.getRetries() < datapoint.getLimit()) {
readDatapoints.add(datapoint);
logger.debug("Could not read value for datapoint {}: {}. Going to retry.",
Expand All @@ -299,9 +302,15 @@ private void readNextQueuedDatapoint() {
logger.warn("Giving up reading datapoint {}, the number of maximum retries ({}) is reached.",
datapoint.getDatapoint().getMainAddress(), datapoint.getLimit());
}
} catch (InterruptedException e) {
} catch (InterruptedException | CancellationException e) {
logger.debug("Interrupted sending KNX read request");
return;
} catch (Exception e) {
// Any other exception: Fail gracefully, i.e. notify user and continue reading next DP.
// Not catching this would end the scheduled read for all DPs in case of an error.
// Severity is warning as this is likely caused by a configuration error.
logger.warn("Error reading datapoint {}: {}", datapoint.getDatapoint().getMainAddress(),
e.getMessage());
}
}
}
Expand Down