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

[netatmo] Prevent IndexOutOfBoundsException #17448

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

clinique
Copy link
Contributor

@clinique clinique commented Sep 20, 2024

Resolves #17446

@clinique clinique added the bug An unexpected problem or unintended behavior of an add-on label Sep 20, 2024
@clinique clinique self-assigned this Sep 20, 2024
@clinique clinique changed the title [netatmo] Preventing IndexOutOfBoundsException [netatmo] Prevent IndexOutOfBoundsException Sep 20, 2024
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single comment

Comment on lines 88 to 89
if (events.size() >= 0) {
HomeEvent oldestRetrieved = events.get(events.size() - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if events.size() is 0 the condition evaluates to true, resulting in a call to events.get(-1); leading to the same exception.
The condition should be:

Suggested change
if (events.size() >= 0) {
HomeEvent oldestRetrieved = events.get(events.size() - 1);
if (events.size() > 0) {
HomeEvent oldestRetrieved = events.get(events.size() - 1);

@lsiepel lsiepel changed the title [netatmo] Prevent IndexOutOfBoundsException [netatmo] Prevent IndexOutOfBoundsException Sep 20, 2024
@lsiepel
Copy link
Contributor

lsiepel commented Sep 20, 2024

Candidate for backporting to 4.2.x

Signed-off-by: Gaël L'hopital <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[netatmo] IndexOutOfBoundsException during camera thing initialization
2 participants