mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
Fix marketplace add-on services fail after upgrade (#3572)
* Fix marketplace add-on services fail after upgrade A format change in the database (related to the introduction of addon.xml) leads to a non-migrateable and permanent error that floods the log with exceptions and malfunctions. If such an error is detected, the database is purged and an error logged. Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
parent
0f1f1729b7
commit
55d6d21f1f
@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
/**
|
||||
* The {@link AbstractRemoteAddonService} implements basic functionality of a remote add-on-service
|
||||
@ -90,8 +91,16 @@ public abstract class AbstractRemoteAddonService implements AddonService {
|
||||
return;
|
||||
}
|
||||
List<Addon> addons = new ArrayList<>();
|
||||
installedAddonStorage.stream().map(e -> Objects.requireNonNull(gson.fromJson(e.getValue(), Addon.class)))
|
||||
.forEach(addons::add);
|
||||
try {
|
||||
installedAddonStorage.stream().map(e -> Objects.requireNonNull(gson.fromJson(e.getValue(), Addon.class)))
|
||||
.forEach(addons::add);
|
||||
} catch (JsonSyntaxException e) {
|
||||
List.copyOf(installedAddonStorage.getKeys()).forEach(installedAddonStorage::remove);
|
||||
logger.error(
|
||||
"Failed to read JSON database, trying to purge it. You might need to re-install {} from the '{}' service.",
|
||||
installedAddonStorage.getKeys(), getId());
|
||||
refreshSource();
|
||||
}
|
||||
|
||||
// create lookup list to make sure installed addons take precedence
|
||||
List<String> installedAddons = addons.stream().map(Addon::getUid).collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user