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

Avoid NPE during Thing update #758

Merged
merged 1 commit into from
Dec 3, 2017
Merged

Conversation

evansj
Copy link
Contributor

@evansj evansj commented Nov 29, 2017

Compare equality using Objects.equals(Object, Object) which is null-safe.

Possible fix for #755.

Also mentioned here: https://community.openhab.org/t/item-update-results-in-exception-occurred-while-calling-thing-updated-at-thinghandler/34526/2

It’s very hard to add a unit test because the updateNodeProperties() method is private and 144 lines long. Would patches to split this function out be acceptable?

An alternative fix would be to simply do:

update = config.equals(originalConfig);

because org.eclipse.smarthome.config.core.Configuration implements the equals method, but then we wouldn’t be able to have the debug messages showing what changed. Having said that, you’ll only see the first changed key logged anyway because of the break statement.

Signed-off-by: Jon Evans [email protected] (github: evansj)

Compare equality using Objects.equals(Object, Object) which is null-safe.

Possible fix for openhab#755.

Also mentioned here: https://community.openhab.org/t/item-update-results-in-exception-occurred-while-calling-thing-updated-at-thinghandler/34526/2

It’s very hard to add a unit test because the updateNodeProperties() method is private and 144 lines long. Would patches to split this function out be acceptable?

An alternative fix would be to simply do:

```java
update = config.equals(originalConfig);
```

because `org.eclipse.smarthome.config.core.Configuration` implements the `equals` method, but then we wouldn’t be able to have the debug messages showing what changed. Having said that, you’ll only see the first changed key logged anyway because of the `break` statement.

Signed-off-by: Jon Evans <[email protected]> (github: evansj)
@cdjackson
Copy link
Collaborator

Thanks. Looks good - if you wanted to add test you can use reflection to change visibility in the test.

Yes, if you want to split out the methods, that's also fine. But note that this will be deleted, so it's probably not worth spending too much time on it here - better to spend time on any such refactoring on a PR into the development branch.

Thanks
Chris

@evansj
Copy link
Contributor Author

evansj commented Nov 29, 2017

Thanks Chris,

Please can you explain "this will be deleted"?

I will do some refactoring against the development branch instead, and create some more PRs.

Cheers
Jon

@cdjackson
Copy link
Collaborator

cdjackson commented Nov 29, 2017 via email

@evansj
Copy link
Contributor Author

evansj commented Nov 29, 2017

Makes sense! Thanks.

@cdjackson cdjackson closed this Dec 3, 2017
@cdjackson cdjackson reopened this Dec 3, 2017
@cdjackson
Copy link
Collaborator

Just reopening to kick off Jenkins again to see if this failure is permanent (shouldn't be I think).

@cdjackson cdjackson merged commit 76b568f into openhab:master Dec 3, 2017
@5iver
Copy link

5iver commented Dec 9, 2017

Will this be merged into the development branch?

@cdjackson
Copy link
Collaborator

cdjackson commented Dec 9, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants