Skip to content

Commit

Permalink
[AddonInfoAddonsXmlProvider] fix issue openhab#3901
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Fiddian-Green <[email protected]>
  • Loading branch information
andrewfg committed Dec 6, 2023
1 parent 44b92db commit 5ffd0c2
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,18 @@ public Set<AddonInfo> getAddonInfos(@Nullable Locale locale) {
}

private void initialize() {
File fileFolder = new File(folder);
try {
if (!fileFolder.isDirectory()) {
logger.warn("Folder '{}' does not exist", folder);
return;
}
} catch (SecurityException e) {
logger.warn("Folder '{}' security exception", folder);
return;
}
AddonInfoListReader reader = new AddonInfoListReader();
Stream.of(new File(folder).listFiles()).filter(f -> f.isFile() && f.getName().endsWith(".xml")).forEach(f -> {
Stream.of(fileFolder.listFiles()).filter(f -> f.isFile() && f.getName().endsWith(".xml")).forEach(f -> {
try {
String xml = Files.readString(f.toPath());
if (xml != null && !xml.isBlank()) {
Expand All @@ -94,6 +104,8 @@ private void initialize() {
logger.warn("File '{}' has invalid content", f.getName());
} catch (XStreamException e) {
logger.warn("File '{}' could not be deserialized", f.getName());
} catch (SecurityException e) {
logger.warn("File '{}' security exception", f.getName());
}
});
}
Expand Down

0 comments on commit 5ffd0c2

Please sign in to comment.