Skip to content

Commit

Permalink
[lgwebos] Update the thing configuration only if the key is different (
Browse files Browse the repository at this point in the history
…openhab#7302)

* [lgwebos] Update the thing configuration only if the key is different

Avoid concurrent edit of thing configuration/properties

Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Hans-Reiner Hoffmann <[email protected]>
  • Loading branch information
lolodomo authored and Hans-Reiner committed Apr 11, 2020
1 parent b0643c2 commit 81e6514
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,21 @@ public String getKey() {

@Override
public void storeKey(@Nullable String key) {
// store it current configuration and avoiding complete re-initialization via handleConfigurationUpdate
getLGWebOSConfig().key = key;

// persist the configuration change
Configuration configuration = editConfiguration();
configuration.put(LGWebOSBindingConstants.CONFIG_KEY, key);
updateConfiguration(configuration);
if (!getKey().equals(key)) {
logger.debug("store new key");
// store it current configuration and avoiding complete re-initialization via handleConfigurationUpdate
getLGWebOSConfig().key = key;

// persist the configuration change
Configuration configuration = editConfiguration();
configuration.put(LGWebOSBindingConstants.CONFIG_KEY, key);
updateConfiguration(configuration);
}
}

@Override
public void storeProperties(Map<String, String> properties) {
logger.debug("storeProperties {}", properties);
Map<String, String> map = editProperties();
map.putAll(properties);
updateProperties(map);
Expand Down

0 comments on commit 81e6514

Please sign in to comment.