Skip to content

Commit

Permalink
fix potential NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K committed Jan 6, 2022
1 parent 695457b commit fc25ddb
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -170,7 +171,12 @@ public void uninstall(String id) {
protected boolean remoteEnabled() {
try {
Configuration configuration = configurationAdmin.getConfiguration("org.openhab.addons", null);
return (boolean) Objects.requireNonNullElse(configuration.getProperties().get("remote"), true);
Dictionary<String, Object> properties = configuration.getProperties();
if (properties == null) {
// if we can't determine a set property, we use true (default is remote enabled)
return true;
}
return (boolean) Objects.requireNonNullElse(properties.get("remote"), true);
} catch (IOException e) {
return true;
}
Expand Down

0 comments on commit fc25ddb

Please sign in to comment.