diff --git a/bundles/org.openhab.core.addon.sample/.classpath b/bundles/org.openhab.core.addon.sample/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.addon.sample/.classpath
+++ b/bundles/org.openhab.core.addon.sample/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.audio/.classpath b/bundles/org.openhab.core.audio/.classpath
index 6bb334a623..14ff44d000 100644
--- a/bundles/org.openhab.core.audio/.classpath
+++ b/bundles/org.openhab.core.audio/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.auth.jaas/.classpath b/bundles/org.openhab.core.auth.jaas/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.auth.jaas/.classpath
+++ b/bundles/org.openhab.core.auth.jaas/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.auth.oauth2client/.classpath b/bundles/org.openhab.core.auth.oauth2client/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.auth.oauth2client/.classpath
+++ b/bundles/org.openhab.core.auth.oauth2client/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.automation.module.media/.classpath b/bundles/org.openhab.core.automation.module.media/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.automation.module.media/.classpath
+++ b/bundles/org.openhab.core.automation.module.media/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/.classpath b/bundles/org.openhab.core.automation.module.script.rulesupport/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/.classpath
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
index d89bdd48cf..e0a440cd0a 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
@@ -186,9 +186,13 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider {
Map scopeValues = new HashMap<>();
Collection values = PRESETS.get(preset);
-
- for (String value : values) {
- scopeValues.put(value, STATIC_TYPES.get(value));
+ if (values != null) {
+ for (String value : values) {
+ Object staticType = STATIC_TYPES.get(value);
+ if (staticType != null) {
+ scopeValues.put(value, staticType);
+ }
+ }
}
if (RULE_SUPPORT.equals(preset)) {
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
index 042460c2ee..3deabaabe9 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
@@ -81,9 +81,10 @@ public class ScriptedCustomModuleTypeProvider implements ModuleTypeProvider {
public void removeModuleType(String moduleTypeUID) {
ModuleType element = modulesTypes.remove(moduleTypeUID);
-
- for (ProviderChangeListener listener : listeners) {
- listener.removed(this, element);
+ if (element != null) {
+ for (ProviderChangeListener listener : listeners) {
+ listener.removed(this, element);
+ }
}
}
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
index 7457c2d404..f98802f195 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
@@ -60,7 +60,10 @@ public class ScriptedRuleProvider implements RuleProvider {
}
public void removeRule(String ruleUID) {
- removeRule(rules.get(ruleUID));
+ Rule rule = rules.get(ruleUID);
+ if (rule != null) {
+ removeRule(rule);
+ }
}
public void removeRule(Rule rule) {
diff --git a/bundles/org.openhab.core.automation.module.script/.classpath b/bundles/org.openhab.core.automation.module.script/.classpath
index e12ef81425..4244343f8a 100644
--- a/bundles/org.openhab.core.automation.module.script/.classpath
+++ b/bundles/org.openhab.core.automation.module.script/.classpath
@@ -8,13 +8,21 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
index d906dae2f3..69a4978072 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
import org.openhab.core.items.ItemNotFoundException;
import org.openhab.core.items.ItemRegistry;
@@ -64,7 +65,10 @@ public class ItemRegistryDelegate implements Map {
}
@Override
- public State get(Object key) {
+ public State get(@Nullable Object key) {
+ if (key == null) {
+ return null;
+ }
final Item item = itemRegistry.get((String) key);
if (item == null) {
return null;
diff --git a/bundles/org.openhab.core.automation.rest/.classpath b/bundles/org.openhab.core.automation.rest/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.automation.rest/.classpath
+++ b/bundles/org.openhab.core.automation.rest/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.automation/.classpath b/bundles/org.openhab.core.automation/.classpath
index 6938cf0e5c..0291b82e45 100644
--- a/bundles/org.openhab.core.automation/.classpath
+++ b/bundles/org.openhab.core.automation/.classpath
@@ -14,11 +14,13 @@
+
+
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
index ab29e8e12e..c86303e1ca 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
@@ -253,7 +253,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider listener : listeners) {
if (oldElement != null) {
@@ -264,7 +264,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider listener : listeners) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
index 41dbb6444e..eea56d03bc 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
@@ -244,7 +244,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider listener : listeners) {
if (oldElement != null) {
@@ -255,7 +255,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider listener : listeners) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
index 9ac3e30692..d0999277b5 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
@@ -107,12 +107,14 @@ public class Printer {
for (int i = 1; i <= ruleUIDs.size(); i++) {
String id = String.valueOf(i);
String uid = ruleUIDs.get(id);
- columnValues.set(0, id);
- columnValues.set(1, uid);
- Rule rule = autoCommands.getRule(uid);
- columnValues.set(2, rule.getName());
- columnValues.set(3, autoCommands.getRuleStatus(uid).toString());
- rulesRows.add(Utils.getRow(columnWidths, columnValues));
+ if (uid != null) {
+ columnValues.set(0, id);
+ columnValues.set(1, uid);
+ Rule rule = autoCommands.getRule(uid);
+ columnValues.set(2, rule.getName());
+ columnValues.set(3, autoCommands.getRuleStatus(uid).toString());
+ rulesRows.add(Utils.getRow(columnWidths, columnValues));
+ }
}
return Utils.getTableContent(TABLE_WIDTH, columnWidths, rulesRows, titleRow);
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
index 3931efd589..cdf14cd4a6 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
@@ -265,11 +265,11 @@ public abstract class AbstractResourceBundleProvider<@NonNull E> {
}
@SuppressWarnings("unchecked")
- protected void removeUninstalledObjects(@Nullable List previousPortfolio, List newPortfolio) {
- if (previousPortfolio != null && !previousPortfolio.isEmpty()) {
- for (String uid : previousPortfolio) {
- if (!newPortfolio.contains(uid)) {
- E removedObject = providedObjectsHolder.remove(uid);
+ protected void removeUninstalledObjects(List previousPortfolio, List newPortfolio) {
+ for (String uid : previousPortfolio) {
+ if (!newPortfolio.contains(uid)) {
+ final @Nullable E removedObject = providedObjectsHolder.remove(uid);
+ if (removedObject != null) {
List> snapshot = null;
synchronized (listeners) {
snapshot = new LinkedList<>(listeners);
@@ -287,11 +287,12 @@ public abstract class AbstractResourceBundleProvider<@NonNull E> {
if (portfolio == null) {
for (Vendor v : providerPortfolio.keySet()) {
if (v.getVendorSymbolicName().equals(vendor.getVendorSymbolicName())) {
- return providerPortfolio.remove(v);
+ List vendorPortfolio = providerPortfolio.remove(v);
+ return vendorPortfolio == null ? List.of() : vendorPortfolio;
}
}
}
- return portfolio;
+ return portfolio == null ? List.of() : portfolio;
}
protected void putNewPortfolio(Vendor vendor, List portfolio) {
@@ -330,13 +331,15 @@ public abstract class AbstractResourceBundleProvider<@NonNull E> {
List portfolio = providerPortfolio.remove(vendor);
if (portfolio != null && !portfolio.isEmpty()) {
for (String uid : portfolio) {
- E removedObject = providedObjectsHolder.remove(uid);
- List> snapshot = null;
- synchronized (listeners) {
- snapshot = new LinkedList<>(listeners);
- }
- for (ProviderChangeListener listener : snapshot) {
- listener.removed((Provider) this, removedObject);
+ final @Nullable E removedObject = providedObjectsHolder.remove(uid);
+ if (removedObject != null) {
+ List> snapshot = null;
+ synchronized (listeners) {
+ snapshot = new LinkedList<>(listeners);
+ }
+ for (ProviderChangeListener listener : snapshot) {
+ listener.removed((Provider) this, removedObject);
+ }
}
}
}
@@ -435,7 +438,7 @@ public abstract class AbstractResourceBundleProvider<@NonNull E> {
}
for (E parsedObject : parsedObjects) {
String uid = getUID(parsedObject);
- E oldElement = providedObjectsHolder.get(uid);
+ final @Nullable E oldElement = providedObjectsHolder.get(uid);
if (oldElement != null && !previousPortfolio.contains(uid)) {
logger.warn("{} with UID '{}' already exists! Failed to add a second with the same UID!",
parsedObject.getClass().getName(), uid);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
index 3b5686a0a5..5ed9ac872a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
@@ -101,7 +101,7 @@ public class RuleResourceBundleImporter extends AbstractResourceBundleProvider vendorPortfolio = providerPortfolio.get(v);
+ return vendorPortfolio == null ? List.of() : vendorPortfolio;
}
}
}
- return portfolio;
+ return portfolio == null ? List.of() : portfolio;
}
@Override
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
index 6b6fe6ebef..ce2bd44172 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.OpenHAB;
import org.openhab.core.automation.parser.Parser;
import org.openhab.core.automation.parser.ParsingException;
@@ -268,14 +269,14 @@ public abstract class AbstractFileProvider<@NonNull E> implements Provider {
for (E providedObject : providedObjects) {
String uid = getUID(providedObject);
uids.add(uid);
- E oldProvidedObject = providedObjectsHolder.put(uid, providedObject);
+ final @Nullable E oldProvidedObject = providedObjectsHolder.put(uid, providedObject);
notifyListeners(oldProvidedObject, providedObject);
}
providerPortfolio.put(url, uids);
}
}
- protected void removeElements(List objectsForRemove) {
+ protected void removeElements(@Nullable List objectsForRemove) {
if (objectsForRemove != null) {
for (String removedObject : objectsForRemove) {
notifyListeners(providedObjectsHolder.remove(removedObject));
@@ -283,7 +284,7 @@ public abstract class AbstractFileProvider<@NonNull E> implements Provider {
}
}
- protected void notifyListeners(E oldElement, E newElement) {
+ protected void notifyListeners(@Nullable E oldElement, E newElement) {
synchronized (listeners) {
for (ProviderChangeListener listener : listeners) {
if (oldElement != null) {
@@ -295,7 +296,7 @@ public abstract class AbstractFileProvider<@NonNull E> implements Provider {
}
}
- protected void notifyListeners(E removedObject) {
+ protected void notifyListeners(@Nullable E removedObject) {
if (removedObject != null) {
synchronized (listeners) {
for (ProviderChangeListener listener : listeners) {
diff --git a/bundles/org.openhab.core.binding.xml/.classpath b/bundles/org.openhab.core.binding.xml/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.binding.xml/.classpath
+++ b/bundles/org.openhab.core.binding.xml/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoConverter.java b/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoConverter.java
index ec190d2c90..3089c513a2 100644
--- a/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoConverter.java
+++ b/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoConverter.java
@@ -85,7 +85,11 @@ public class BindingInfoConverter extends GenericUnmarshaller attributes = this.attributeMapValidator.readValidatedAttributes(reader);
+
String id = attributes.get("id");
+ if (id == null) {
+ throw new ConversionException("Binding id attribute is null");
+ }
// set automatically extracted URI for a possible 'config-description' section
context.put("config-description.uri", "binding:" + id);
diff --git a/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoReader.java b/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoReader.java
index 77b6e2e9c3..fd85fe4954 100644
--- a/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoReader.java
+++ b/bundles/org.openhab.core.binding.xml/src/main/java/org/openhab/core/binding/xml/internal/BindingInfoReader.java
@@ -49,7 +49,10 @@ public class BindingInfoReader extends XmlDocumentReader {
* The default constructor of this class.
*/
public BindingInfoReader() {
- super.setClassLoader(BindingInfoReader.class.getClassLoader());
+ ClassLoader classLoader = BindingInfoReader.class.getClassLoader();
+ if (classLoader != null) {
+ super.setClassLoader(classLoader);
+ }
}
@Override
diff --git a/bundles/org.openhab.core.config.core/.classpath b/bundles/org.openhab.core.config.core/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.config.core/.classpath
+++ b/bundles/org.openhab.core.config.core/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery.mdns/.classpath b/bundles/org.openhab.core.config.discovery.mdns/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.discovery.mdns/.classpath
+++ b/bundles/org.openhab.core.config.discovery.mdns/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery.upnp/.classpath b/bundles/org.openhab.core.config.discovery.upnp/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.discovery.upnp/.classpath
+++ b/bundles/org.openhab.core.config.discovery.upnp/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/.classpath b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/.classpath
+++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery.usbserial/.classpath b/bundles/org.openhab.core.config.discovery.usbserial/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.discovery.usbserial/.classpath
+++ b/bundles/org.openhab.core.config.discovery.usbserial/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery/.classpath b/bundles/org.openhab.core.config.discovery/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.config.discovery/.classpath
+++ b/bundles/org.openhab.core.config.discovery/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java
index 1ecd568c68..4df3546a24 100644
--- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java
+++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -534,13 +535,15 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
final List configDescParams = getConfigDescParams(discoveryResult);
final Set paramNames = getConfigDescParamNames(configDescParams);
final Map resultProps = discoveryResult.getProperties();
- for (String resultKey : resultProps.keySet()) {
+ for (Entry resultEntry : resultProps.entrySet()) {
+ String resultKey = resultEntry.getKey();
+ Object resultValue = resultEntry.getValue();
if (paramNames.contains(resultKey)) {
ConfigDescriptionParameter param = getConfigDescriptionParam(configDescParams, resultKey);
- Object normalizedValue = ConfigUtil.normalizeType(resultProps.get(resultKey), param);
+ Object normalizedValue = ConfigUtil.normalizeType(resultValue, param);
configParams.put(resultKey, normalizedValue);
} else {
- props.put(resultKey, String.valueOf(resultProps.get(resultKey)));
+ props.put(resultKey, String.valueOf(resultValue));
}
}
}
diff --git a/bundles/org.openhab.core.config.dispatch/.classpath b/bundles/org.openhab.core.config.dispatch/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.dispatch/.classpath
+++ b/bundles/org.openhab.core.config.dispatch/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.serial/.classpath b/bundles/org.openhab.core.config.serial/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.serial/.classpath
+++ b/bundles/org.openhab.core.config.serial/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.xml/.classpath b/bundles/org.openhab.core.config.xml/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.config.xml/.classpath
+++ b/bundles/org.openhab.core.config.xml/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/AbstractXmlBasedProvider.java b/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/AbstractXmlBasedProvider.java
index 5a330ad608..56ada688f6 100644
--- a/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/AbstractXmlBasedProvider.java
+++ b/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/AbstractXmlBasedProvider.java
@@ -165,16 +165,14 @@ public abstract class AbstractXmlBasedProvider<@NonNull T_ID, @NonNull T_OBJECT
private T_OBJECT acquireLocalizedObject(Bundle bundle, T_OBJECT object, @Nullable Locale locale) {
final LocalizedKey localizedKey = getLocalizedKey(object, locale);
- final T_OBJECT cacheEntry = localizedObjectCache.get(localizedKey);
+ final @Nullable T_OBJECT cacheEntry = localizedObjectCache.get(localizedKey);
if (cacheEntry != null) {
return cacheEntry;
}
- @Nullable
- final T_OBJECT localizedObject = localize(bundle, object, locale);
+ final @Nullable T_OBJECT localizedObject = localize(bundle, object, locale);
if (localizedObject != null) {
- @NonNull
- T_OBJECT nonNullLocalizedObject = (@NonNull T_OBJECT) localizedObject;
+ T_OBJECT nonNullLocalizedObject = localizedObject;
localizedObjectCache.put(localizedKey, nonNullLocalizedObject);
return localizedObject;
} else {
diff --git a/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/internal/ConfigDescriptionReader.java b/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/internal/ConfigDescriptionReader.java
index 6b58520f00..6029815ddd 100644
--- a/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/internal/ConfigDescriptionReader.java
+++ b/bundles/org.openhab.core.config.xml/src/main/java/org/openhab/core/config/xml/internal/ConfigDescriptionReader.java
@@ -50,7 +50,10 @@ public class ConfigDescriptionReader extends XmlDocumentReader
+
+
diff --git a/bundles/org.openhab.core.id/.classpath b/bundles/org.openhab.core.id/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.id/.classpath
+++ b/bundles/org.openhab.core.id/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.bin2json/.classpath b/bundles/org.openhab.core.io.bin2json/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.bin2json/.classpath
+++ b/bundles/org.openhab.core.io.bin2json/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.console.eclipse/.classpath b/bundles/org.openhab.core.io.console.eclipse/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.console.eclipse/.classpath
+++ b/bundles/org.openhab.core.io.console.eclipse/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.console.karaf/.classpath b/bundles/org.openhab.core.io.console.karaf/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.console.karaf/.classpath
+++ b/bundles/org.openhab.core.io.console.karaf/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.console.rfc147/.classpath b/bundles/org.openhab.core.io.console.rfc147/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.console.rfc147/.classpath
+++ b/bundles/org.openhab.core.io.console.rfc147/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.console/.classpath b/bundles/org.openhab.core.io.console/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.console/.classpath
+++ b/bundles/org.openhab.core.io.console/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.http.auth.basic/.classpath b/bundles/org.openhab.core.io.http.auth.basic/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.http.auth.basic/.classpath
+++ b/bundles/org.openhab.core.io.http.auth.basic/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.http.auth/.classpath b/bundles/org.openhab.core.io.http.auth/.classpath
index 3721ade03c..01095f5fb4 100644
--- a/bundles/org.openhab.core.io.http.auth/.classpath
+++ b/bundles/org.openhab.core.io.http.auth/.classpath
@@ -9,11 +9,13 @@
+
+
@@ -23,5 +25,10 @@
+
+
+
+
+
diff --git a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java
index 9e1f1ad977..0511074be5 100644
--- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java
+++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java
@@ -117,7 +117,7 @@ public abstract class AbstractAuthPageServlet extends HttpServlet {
return user;
}
- protected void processFailedLogin(HttpServletResponse resp, Map params, String message)
+ protected void processFailedLogin(HttpServletResponse resp, Map params, @Nullable String message)
throws IOException {
lastAuthenticationFailure = Instant.now();
authenticationFailureCount += 1;
diff --git a/bundles/org.openhab.core.io.http/.classpath b/bundles/org.openhab.core.io.http/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.http/.classpath
+++ b/bundles/org.openhab.core.io.http/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.jetty.certificate/.classpath b/bundles/org.openhab.core.io.jetty.certificate/.classpath
index 4559ca0b25..405456d1da 100644
--- a/bundles/org.openhab.core.io.jetty.certificate/.classpath
+++ b/bundles/org.openhab.core.io.jetty.certificate/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.monitor/.classpath b/bundles/org.openhab.core.io.monitor/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.monitor/.classpath
+++ b/bundles/org.openhab.core.io.monitor/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.net/.classpath b/bundles/org.openhab.core.io.net/.classpath
index 8527f13565..2a0f2f3ccf 100644
--- a/bundles/org.openhab.core.io.net/.classpath
+++ b/bundles/org.openhab.core.io.net/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.audio/.classpath b/bundles/org.openhab.core.io.rest.audio/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.audio/.classpath
+++ b/bundles/org.openhab.core.io.rest.audio/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.auth/.classpath b/bundles/org.openhab.core.io.rest.auth/.classpath
index 4559ca0b25..600c3686ed 100644
--- a/bundles/org.openhab.core.io.rest.auth/.classpath
+++ b/bundles/org.openhab.core.io.rest.auth/.classpath
@@ -16,9 +16,16 @@
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.io.rest.core/.classpath b/bundles/org.openhab.core.io.rest.core/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.core/.classpath
+++ b/bundles/org.openhab.core.io.rest.core/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java
index fd6c5e9970..d48e6a1caf 100644
--- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java
+++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java
@@ -214,7 +214,7 @@ public class AddonResource implements RESTResource {
return Response.ok(null, MediaType.TEXT_PLAIN).build();
}
- private void postFailureEvent(String addonId, String msg) {
+ private void postFailureEvent(String addonId, @Nullable String msg) {
Event event = AddonEventFactory.createAddonFailureEvent(addonId, msg);
eventPublisher.post(event);
}
diff --git a/bundles/org.openhab.core.io.rest.log/.classpath b/bundles/org.openhab.core.io.rest.log/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.log/.classpath
+++ b/bundles/org.openhab.core.io.rest.log/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.mdns/.classpath b/bundles/org.openhab.core.io.rest.mdns/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.mdns/.classpath
+++ b/bundles/org.openhab.core.io.rest.mdns/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.sitemap/.classpath b/bundles/org.openhab.core.io.rest.sitemap/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.sitemap/.classpath
+++ b/bundles/org.openhab.core.io.rest.sitemap/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.sse/.classpath b/bundles/org.openhab.core.io.rest.sse/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.sse/.classpath
+++ b/bundles/org.openhab.core.io.rest.sse/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.swagger/.classpath b/bundles/org.openhab.core.io.rest.swagger/.classpath
index 4559ca0b25..405456d1da 100644
--- a/bundles/org.openhab.core.io.rest.swagger/.classpath
+++ b/bundles/org.openhab.core.io.rest.swagger/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.ui/.classpath b/bundles/org.openhab.core.io.rest.ui/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.ui/.classpath
+++ b/bundles/org.openhab.core.io.rest.ui/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest.voice/.classpath b/bundles/org.openhab.core.io.rest.voice/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest.voice/.classpath
+++ b/bundles/org.openhab.core.io.rest.voice/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest/.classpath b/bundles/org.openhab.core.io.rest/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.rest/.classpath
+++ b/bundles/org.openhab.core.io.rest/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java
index 42fc25043e..9b6e081110 100644
--- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java
+++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java
@@ -146,8 +146,10 @@ public class SseBroadcaster<@NonNull I> implements Closeable {
}
private void handleRemoval(final SseEventSink sink) {
- final I info = sinks.remove(sink);
- notifyAboutRemoval(sink, info);
+ final @Nullable I info = sinks.remove(sink);
+ if (info != null) {
+ notifyAboutRemoval(sink, info);
+ }
}
private void notifyAboutRemoval(final SseEventSink sink, I info) {
diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java
index b816c4f7ca..b92f73beaa 100644
--- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java
+++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java
@@ -13,6 +13,7 @@
package org.openhab.core.io.rest.internal.resources.beans;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.OpenHAB;
/**
@@ -28,13 +29,13 @@ public class SystemInfoBean {
public static class SystemInfo {
public final String configFolder = OpenHAB.getConfigFolder();
public final String userdataFolder = OpenHAB.getUserDataFolder();
- public final String logFolder = System.getProperty("openhab.logdir");
- public final String javaVersion = System.getProperty("java.version");
- public final String javaVendor = System.getProperty("java.vendor");
- public final String javaVendorVersion = System.getProperty("java.vendor.version");
- public final String osName = System.getProperty("os.name");
- public final String osVersion = System.getProperty("os.version");
- public final String osArchitecture = System.getProperty("os.arch");
+ public final @Nullable String logFolder = System.getProperty("openhab.logdir");
+ public final @Nullable String javaVersion = System.getProperty("java.version");
+ public final @Nullable String javaVendor = System.getProperty("java.vendor");
+ public final @Nullable String javaVendorVersion = System.getProperty("java.vendor.version");
+ public final @Nullable String osName = System.getProperty("os.name");
+ public final @Nullable String osVersion = System.getProperty("os.version");
+ public final @Nullable String osArchitecture = System.getProperty("os.arch");
public final int availableProcessors = Runtime.getRuntime().availableProcessors();
public final long freeMemory = Runtime.getRuntime().freeMemory();
public final long totalMemory = Runtime.getRuntime().totalMemory();
diff --git a/bundles/org.openhab.core.io.transport.mdns/.classpath b/bundles/org.openhab.core.io.transport.mdns/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.mdns/.classpath
+++ b/bundles/org.openhab.core.io.transport.mdns/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.mqtt/.classpath b/bundles/org.openhab.core.io.transport.mqtt/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.io.transport.mqtt/.classpath
+++ b/bundles/org.openhab.core.io.transport.mqtt/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java
index 909870b8c2..522996a247 100644
--- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java
+++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java
@@ -13,6 +13,7 @@
package org.openhab.core.io.transport.mqtt;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
/**
* Thrown if an error occurs communicating with the server. The exception contains a reason code. The semantic of the
@@ -51,7 +52,7 @@ public class MqttException extends Exception {
* which may be null
.
*/
@Override
- public Throwable getCause() {
+ public @Nullable Throwable getCause() {
return cause;
}
@@ -59,7 +60,7 @@ public class MqttException extends Exception {
* Returns the detail message for this exception. May be null.
*/
@Override
- public String getMessage() {
+ public @Nullable String getMessage() {
return cause.getMessage();
}
diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java
index 89382fe4f6..d90b8f1731 100644
--- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java
+++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java
@@ -156,14 +156,12 @@ public class MqttWillAndTestament {
@Override
public String toString() {
+ byte[] localPayload = this.payload;
+
StringBuilder sb = new StringBuilder();
sb.append("[").append(getClass());
sb.append("] Send '");
- if (payload != null) {
- sb.append(new String(payload));
- } else {
- sb.append(payload);
- }
+ sb.append(localPayload == null ? localPayload : new String(localPayload));
sb.append("' to topic '");
sb.append(topic);
sb.append("'");
diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java
index 253739b5ef..31d71b3791 100644
--- a/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java
+++ b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java
@@ -46,6 +46,12 @@ import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish;
*/
@NonNullByDefault
public class MqttBrokerConnectionTests extends JavaTest {
+ private static final byte[] HELLO_BYTES = "hello".getBytes();
+
+ private static byte[] eqHelloBytes() {
+ return eq(HELLO_BYTES);
+ }
+
@Test
public void subscribeBeforeOnlineThenConnect()
throws ConfigurationException, MqttException, InterruptedException, ExecutionException, TimeoutException {
@@ -60,11 +66,11 @@ public class MqttBrokerConnectionTests extends JavaTest {
assertTrue(connection.hasSubscribers());
assertThat(connection.connectionState(), is(MqttConnectionState.CONNECTED));
- Mqtt3Publish publishMessage = Mqtt3Publish.builder().topic("homie/device123/$name").payload("hello".getBytes())
+ Mqtt3Publish publishMessage = Mqtt3Publish.builder().topic("homie/device123/$name").payload(HELLO_BYTES)
.build();
// Test if subscription is active
connection.getSubscribers().get("homie/device123/$name").messageArrived(publishMessage);
- verify(subscriber).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
+ verify(subscriber).processMessage(eq("homie/device123/$name"), eqHelloBytes());
}
@Test
@@ -87,15 +93,15 @@ public class MqttBrokerConnectionTests extends JavaTest {
assertTrue(connection.hasSubscribers());
assertThat(connection.connectionState(), is(MqttConnectionState.CONNECTED));
- Mqtt3Publish publishMessage = Mqtt3Publish.builder().topic("homie/device123/$name").payload("hello".getBytes())
+ Mqtt3Publish publishMessage = Mqtt3Publish.builder().topic("homie/device123/$name").payload(HELLO_BYTES)
.build();
connection.getSubscribers().get("homie/device123/+").messageArrived(publishMessage);
connection.getSubscribers().get("#").messageArrived(publishMessage);
connection.getSubscribers().get("homie/#").messageArrived(publishMessage);
- verify(subscriber).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
- verify(subscriber2).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
- verify(subscriber3).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
+ verify(subscriber).processMessage(eq("homie/device123/$name"), eqHelloBytes());
+ verify(subscriber2).processMessage(eq("homie/device123/$name"), eqHelloBytes());
+ verify(subscriber3).processMessage(eq("homie/device123/$name"), eqHelloBytes());
}
@Test
diff --git a/bundles/org.openhab.core.io.transport.serial.javacomm/.classpath b/bundles/org.openhab.core.io.transport.serial.javacomm/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.serial.javacomm/.classpath
+++ b/bundles/org.openhab.core.io.transport.serial.javacomm/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/.classpath b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/.classpath
+++ b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx/.classpath b/bundles/org.openhab.core.io.transport.serial.rxtx/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.serial.rxtx/.classpath
+++ b/bundles/org.openhab.core.io.transport.serial.rxtx/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java
index bc1292a64a..ef6bf094f2 100644
--- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java
+++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java
@@ -78,7 +78,9 @@ public class SerialPortUtil {
System.clearProperty(GNU_IO_RXTX_SERIAL_PORTS);
identifiers = CommPortIdentifier.getPortIdentifiers();
// Restore the existing serial ports property
- System.setProperty(GNU_IO_RXTX_SERIAL_PORTS, value);
+ if (value != null) {
+ System.setProperty(GNU_IO_RXTX_SERIAL_PORTS, value);
+ }
} else {
identifiers = CommPortIdentifier.getPortIdentifiers();
}
diff --git a/bundles/org.openhab.core.io.transport.serial/.classpath b/bundles/org.openhab.core.io.transport.serial/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.serial/.classpath
+++ b/bundles/org.openhab.core.io.transport.serial/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.io.transport.upnp/.classpath b/bundles/org.openhab.core.io.transport.upnp/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.io.transport.upnp/.classpath
+++ b/bundles/org.openhab.core.io.transport.upnp/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.karaf/.classpath b/bundles/org.openhab.core.karaf/.classpath
index 234db15be4..6c969470df 100644
--- a/bundles/org.openhab.core.karaf/.classpath
+++ b/bundles/org.openhab.core.karaf/.classpath
@@ -21,11 +21,13 @@
+
+
diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/command/InstallServiceCommand.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/command/InstallServiceCommand.java
index fe9847862a..9640f78e97 100644
--- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/command/InstallServiceCommand.java
+++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/command/InstallServiceCommand.java
@@ -100,8 +100,13 @@ public class InstallServiceCommand implements Action {
String karafBase = System.getProperty("karaf.base");
String karafHome = System.getProperty("karaf.home");
- // can we install to karaf.home?
- if (!new File(karafHome).canWrite()) {
+ if (karafBase == null) {
+ System.out.println("System property karaf.base is not set. Install aborted.");
+ return null;
+ } else if (karafHome == null) {
+ System.out.println("System property karaf.home is not set. Install aborted.");
+ return null;
+ } else if (!new File(karafHome).canWrite()) {
System.out.println("Cannot write to " + karafHome + ". Install aborted.");
return null;
}
diff --git a/bundles/org.openhab.core.model.core/.classpath b/bundles/org.openhab.core.model.core/.classpath
index 4a6392d139..2b32b53570 100644
--- a/bundles/org.openhab.core.model.core/.classpath
+++ b/bundles/org.openhab.core.model.core/.classpath
@@ -14,11 +14,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.item.ide/.classpath b/bundles/org.openhab.core.model.item.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.item.ide/.classpath
+++ b/bundles/org.openhab.core.model.item.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.item.runtime/.classpath b/bundles/org.openhab.core.model.item.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.item.runtime/.classpath
+++ b/bundles/org.openhab.core.model.item.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.item/.classpath b/bundles/org.openhab.core.model.item/.classpath
index 6efc940d8e..8d82a9ce38 100644
--- a/bundles/org.openhab.core.model.item/.classpath
+++ b/bundles/org.openhab.core.model.item/.classpath
@@ -26,11 +26,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java
index 5d3880d469..1aa48bc73b 100644
--- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java
+++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java
@@ -393,8 +393,8 @@ public class GenericItemProvider extends AbstractProvider-
Map newItems = toItemMap(getItemsFromModel(modelName));
itemsMap.put(modelName, newItems.values());
for (Item newItem : newItems.values()) {
- if (oldItems.containsKey(newItem.getName())) {
- Item oldItem = oldItems.get(newItem.getName());
+ Item oldItem = oldItems.get(newItem.getName());
+ if (oldItem != null) {
if (hasItemChanged(oldItem, newItem)) {
notifyListenersAboutUpdatedElement(oldItem, newItem);
}
@@ -473,7 +473,7 @@ public class GenericItemProvider extends AbstractProvider
-
return !(sameBaseItemClass && sameFunction);
}
- private Map toItemMap(Collection
- items) {
+ private Map toItemMap(@Nullable Collection
- items) {
if (items == null || items.isEmpty()) {
return Collections.emptyMap();
}
diff --git a/bundles/org.openhab.core.model.lazygen/.classpath b/bundles/org.openhab.core.model.lazygen/.classpath
index 4a6392d139..2b32b53570 100644
--- a/bundles/org.openhab.core.model.lazygen/.classpath
+++ b/bundles/org.openhab.core.model.lazygen/.classpath
@@ -14,11 +14,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.lsp/.classpath b/bundles/org.openhab.core.model.lsp/.classpath
index 4689975be0..3f7ff5372d 100644
--- a/bundles/org.openhab.core.model.lsp/.classpath
+++ b/bundles/org.openhab.core.model.lsp/.classpath
@@ -21,11 +21,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java
index dbcc60f8ed..4018bb6e08 100644
--- a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java
+++ b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java
@@ -57,14 +57,14 @@ public class MappingUriExtensions extends UriExtensions {
@Override
public URI toUri(String pathWithScheme) {
String decodedPathWithScheme = URLDecoder.decode(pathWithScheme, StandardCharsets.UTF_8);
-
- if (clientLocation != null && decodedPathWithScheme.startsWith(clientLocation)) {
+ String localClientLocation = clientLocation;
+ if (localClientLocation != null && decodedPathWithScheme.startsWith(localClientLocation)) {
return map(decodedPathWithScheme);
}
- clientLocation = guessClientPath(decodedPathWithScheme);
- if (clientLocation != null) {
- logger.debug("Identified client workspace as '{}'", clientLocation);
+ localClientLocation = clientLocation = guessClientPath(decodedPathWithScheme);
+ if (localClientLocation != null) {
+ logger.debug("Identified client workspace as '{}'", localClientLocation);
return map(decodedPathWithScheme);
}
@@ -89,8 +89,10 @@ public class MappingUriExtensions extends UriExtensions {
}
private String mapToClientPath(String pathWithScheme) {
- String clientPath = toPathAsInXtext212(
- java.net.URI.create(pathWithScheme.replace(serverLocation, clientLocation)));
+ String clientLocation = this.clientLocation;
+ String uriString = clientLocation == null ? serverLocation
+ : pathWithScheme.replace(serverLocation, clientLocation);
+ String clientPath = toPathAsInXtext212(java.net.URI.create(uriString));
logger.trace("Mapping server path {} to client path {}", pathWithScheme, clientPath);
return clientPath;
}
diff --git a/bundles/org.openhab.core.model.persistence.ide/.classpath b/bundles/org.openhab.core.model.persistence.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.persistence.ide/.classpath
+++ b/bundles/org.openhab.core.model.persistence.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.persistence.runtime/.classpath b/bundles/org.openhab.core.model.persistence.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.persistence.runtime/.classpath
+++ b/bundles/org.openhab.core.model.persistence.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.persistence/.classpath b/bundles/org.openhab.core.model.persistence/.classpath
index 6efc940d8e..8d82a9ce38 100644
--- a/bundles/org.openhab.core.model.persistence/.classpath
+++ b/bundles/org.openhab.core.model.persistence/.classpath
@@ -26,11 +26,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.model.rule.ide/.classpath b/bundles/org.openhab.core.model.rule.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.rule.ide/.classpath
+++ b/bundles/org.openhab.core.model.rule.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.rule.runtime/.classpath b/bundles/org.openhab.core.model.rule.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.rule.runtime/.classpath
+++ b/bundles/org.openhab.core.model.rule.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.rule/.classpath b/bundles/org.openhab.core.model.rule/.classpath
index 6efc940d8e..8d82a9ce38 100644
--- a/bundles/org.openhab.core.model.rule/.classpath
+++ b/bundles/org.openhab.core.model.rule/.classpath
@@ -26,11 +26,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.model.script.ide/.classpath b/bundles/org.openhab.core.model.script.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.script.ide/.classpath
+++ b/bundles/org.openhab.core.model.script.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.script.runtime/.classpath b/bundles/org.openhab.core.model.script.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.script.runtime/.classpath
+++ b/bundles/org.openhab.core.model.script.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.script/.classpath b/bundles/org.openhab.core.model.script/.classpath
index 8f2f63af3a..e7192c11ae 100644
--- a/bundles/org.openhab.core.model.script/.classpath
+++ b/bundles/org.openhab.core.model.script/.classpath
@@ -38,11 +38,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.sitemap.ide/.classpath b/bundles/org.openhab.core.model.sitemap.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.sitemap.ide/.classpath
+++ b/bundles/org.openhab.core.model.sitemap.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.sitemap.runtime/.classpath b/bundles/org.openhab.core.model.sitemap.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.sitemap.runtime/.classpath
+++ b/bundles/org.openhab.core.model.sitemap.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.sitemap/.classpath b/bundles/org.openhab.core.model.sitemap/.classpath
index 6efc940d8e..8d82a9ce38 100644
--- a/bundles/org.openhab.core.model.sitemap/.classpath
+++ b/bundles/org.openhab.core.model.sitemap/.classpath
@@ -26,11 +26,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java
index 8df285f2cb..24844477c3 100644
--- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java
+++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java
@@ -111,7 +111,10 @@ public class SitemapProviderImpl implements SitemapProvider, ModelRepositoryChan
sitemapModelCache.clear();
Iterable sitemapNames = modelRepo.getAllModelNamesOfType(SITEMAP_MODEL_NAME);
for (String sitemapName : sitemapNames) {
- sitemapModelCache.put(sitemapName, (Sitemap) modelRepo.getModel(sitemapName));
+ Sitemap sitemap = (Sitemap) modelRepo.getModel(sitemapName);
+ if (sitemap != null) {
+ sitemapModelCache.put(sitemapName, sitemap);
+ }
}
}
diff --git a/bundles/org.openhab.core.model.thing.ide/.classpath b/bundles/org.openhab.core.model.thing.ide/.classpath
index 85339b176c..4bf140abc3 100644
--- a/bundles/org.openhab.core.model.thing.ide/.classpath
+++ b/bundles/org.openhab.core.model.thing.ide/.classpath
@@ -28,11 +28,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.thing.runtime/.classpath b/bundles/org.openhab.core.model.thing.runtime/.classpath
index 275d188768..5ce171e7ae 100644
--- a/bundles/org.openhab.core.model.thing.runtime/.classpath
+++ b/bundles/org.openhab.core.model.thing.runtime/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.model.thing/.classpath b/bundles/org.openhab.core.model.thing/.classpath
index 84d4f01a10..9485298c10 100644
--- a/bundles/org.openhab.core.model.thing/.classpath
+++ b/bundles/org.openhab.core.model.thing/.classpath
@@ -33,11 +33,13 @@
+
+
diff --git a/bundles/org.openhab.core.persistence/.classpath b/bundles/org.openhab.core.persistence/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.persistence/.classpath
+++ b/bundles/org.openhab.core.persistence/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java
index 826a70090f..b0103f9372 100644
--- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java
+++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java
@@ -387,8 +387,9 @@ public class PersistenceManagerImpl implements ItemRegistryChangeListener, Persi
public void removeConfig(final String dbId) {
synchronized (persistenceServiceConfigs) {
stopEventHandling(dbId);
- if (persistenceServices.containsKey(dbId)) {
- persistenceServiceConfigs.put(dbId, getDefaultConfig(persistenceServices.get(dbId)));
+ PersistenceService persistenceService = persistenceServices.get(dbId);
+ if (persistenceService != null) {
+ persistenceServiceConfigs.put(dbId, getDefaultConfig(persistenceService));
startEventHandling(dbId);
} else {
persistenceServiceConfigs.remove(dbId);
diff --git a/bundles/org.openhab.core.semantics/.classpath b/bundles/org.openhab.core.semantics/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.semantics/.classpath
+++ b/bundles/org.openhab.core.semantics/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.storage.json/.classpath b/bundles/org.openhab.core.storage.json/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.storage.json/.classpath
+++ b/bundles/org.openhab.core.storage.json/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java
index 1d5eb8262c..46f7b646d1 100644
--- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java
+++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java
@@ -79,29 +79,31 @@ public class JsonStorageService implements StorageService {
return;
}
+ Object value = properties.get(CFG_MAX_BACKUP_FILES);
try {
- if (properties.get(CFG_MAX_BACKUP_FILES) != null) {
- maxBackupFiles = Integer.parseInt((String) properties.get(CFG_MAX_BACKUP_FILES));
+ if (value != null) {
+ maxBackupFiles = Integer.parseInt((String) value);
}
} catch (NumberFormatException nfe) {
- logger.error("Value {} for {} is invalid. Using {}.", properties.get(CFG_MAX_BACKUP_FILES),
- CFG_MAX_BACKUP_FILES, maxBackupFiles);
+ logger.error("Value {} for {} is invalid. Using {}.", value, CFG_MAX_BACKUP_FILES, maxBackupFiles);
}
+
+ value = properties.get(CFG_WRITE_DELAY);
try {
- if (properties.get(CFG_WRITE_DELAY) != null) {
- writeDelay = Integer.parseInt((String) properties.get(CFG_WRITE_DELAY));
+ if (value != null) {
+ writeDelay = Integer.parseInt((String) value);
}
} catch (NumberFormatException nfe) {
- logger.error("Value {} for {} is invalid. Using {}.", properties.get(CFG_WRITE_DELAY), CFG_WRITE_DELAY,
- writeDelay);
+ logger.error("Value {} for {} is invalid. Using {}.", value, CFG_WRITE_DELAY, writeDelay);
}
+
+ value = properties.get(CFG_MAX_DEFER_DELAY);
try {
- if (properties.get(CFG_MAX_DEFER_DELAY) != null) {
- maxDeferredPeriod = Integer.parseInt((String) properties.get(CFG_MAX_DEFER_DELAY));
+ if (value != null) {
+ maxDeferredPeriod = Integer.parseInt((String) value);
}
} catch (NumberFormatException nfe) {
- logger.error("Value {} for {} is invalid. Using {}.", properties.get(CFG_MAX_DEFER_DELAY),
- CFG_MAX_DEFER_DELAY, maxDeferredPeriod);
+ logger.error("Value {} for {} is invalid. Using {}.", value, CFG_MAX_DEFER_DELAY, maxDeferredPeriod);
}
}
diff --git a/bundles/org.openhab.core.test.magic/.classpath b/bundles/org.openhab.core.test.magic/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.test.magic/.classpath
+++ b/bundles/org.openhab.core.test.magic/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.test/.classpath b/bundles/org.openhab.core.test/.classpath
index 4559ca0b25..405456d1da 100644
--- a/bundles/org.openhab.core.test/.classpath
+++ b/bundles/org.openhab.core.test/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java
index d0b974eaf7..c175f67494 100644
--- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java
+++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java
@@ -32,10 +32,12 @@ public class VolatileStorageService implements StorageService {
@Override
@SuppressWarnings("unchecked")
public synchronized Storage getStorage(String name) {
- if (!storages.containsKey(name)) {
- storages.put(name, new VolatileStorage<>());
+ Storage storage = storages.get(name);
+ if (storage == null) {
+ storage = new VolatileStorage<>();
+ storages.put(name, storage);
}
- return storages.get(name);
+ return storage;
}
@Override
diff --git a/bundles/org.openhab.core.thing.xml/.classpath b/bundles/org.openhab.core.thing.xml/.classpath
index 8527f13565..2a0f2f3ccf 100644
--- a/bundles/org.openhab.core.thing.xml/.classpath
+++ b/bundles/org.openhab.core.thing.xml/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java b/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java
index 3e4a041405..b1ad47fd8f 100644
--- a/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java
+++ b/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java
@@ -18,6 +18,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.xml.util.ConverterAttributeMapValidator;
import org.openhab.core.config.xml.util.GenericUnmarshaller;
import org.openhab.core.config.xml.util.NodeIterator;
@@ -41,6 +43,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
*
* @author Michael Grammling - Initial contribution
*/
+@NonNullByDefault
public class StateDescriptionConverter extends GenericUnmarshaller {
protected ConverterAttributeMapValidator attributeMapValidator;
@@ -52,8 +55,8 @@ public class StateDescriptionConverter extends GenericUnmarshaller attributes, String attribute, BigDecimal defaultValue)
- throws ConversionException {
+ private @Nullable BigDecimal toBigDecimal(Map attributes, String attribute,
+ @Nullable BigDecimal defaultValue) throws ConversionException {
String attrValueText = attributes.get(attribute);
if (attrValueText != null) {
@@ -68,14 +71,9 @@ public class StateDescriptionConverter extends GenericUnmarshaller attributes, String attribute, Boolean defaultValue) {
+ private boolean toBoolean(Map attributes, String attribute, boolean defaultValue) {
String attrValueText = attributes.get(attribute);
-
- if (attrValueText != null) {
- return Boolean.valueOf(attrValueText);
- }
-
- return defaultValue;
+ return attrValueText == null ? defaultValue : Boolean.valueOf(attrValueText);
}
private List toListOfChannelState(NodeList nodeList) throws ConversionException {
@@ -104,28 +102,43 @@ public class StateDescriptionConverter extends GenericUnmarshaller attributes = this.attributeMapValidator.readValidatedAttributes(reader);
- BigDecimal minimum = toBigDecimal(attributes, "min", null);
- BigDecimal maximum = toBigDecimal(attributes, "max", null);
- BigDecimal step = toBigDecimal(attributes, "step", null);
- String pattern = attributes.get("pattern");
boolean readOnly = toBoolean(attributes, "readOnly", false);
+ StateDescriptionFragmentBuilder builder = StateDescriptionFragmentBuilder.create().withReadOnly(readOnly);
- StateDescriptionFragmentBuilder stateDescriptionFragmentBuilder = StateDescriptionFragmentBuilder.create()
- .withMinimum(minimum).withMaximum(maximum).withStep(step).withPattern(pattern).withReadOnly(readOnly);
+ BigDecimal minimum = toBigDecimal(attributes, "min", null);
+ if (minimum != null) {
+ builder.withMinimum(minimum);
+ }
+
+ BigDecimal maximum = toBigDecimal(attributes, "max", null);
+ if (maximum != null) {
+ builder.withMaximum(maximum);
+ }
+
+ BigDecimal step = toBigDecimal(attributes, "step", null);
+ if (step != null) {
+ builder.withStep(step);
+ }
+
+ String pattern = attributes.get("pattern");
+ if (pattern != null) {
+ builder.withPattern(pattern);
+ }
NodeList nodes = (NodeList) context.convertAnother(context, NodeList.class);
NodeIterator nodeIterator = new NodeIterator(nodes.getList());
NodeList optionNodes = (NodeList) nodeIterator.next();
if (optionNodes != null) {
- stateDescriptionFragmentBuilder.withOptions(toListOfChannelState(optionNodes));
+ builder.withOptions(toListOfChannelState(optionNodes));
}
nodeIterator.assertEndOfType();
- return stateDescriptionFragmentBuilder.build().toStateDescription();
+ return builder.build().toStateDescription();
}
}
diff --git a/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java b/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java
index 204aea176b..6e9faab38e 100644
--- a/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java
+++ b/bundles/org.openhab.core.thing.xml/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java
@@ -56,7 +56,10 @@ public class ThingDescriptionReader extends XmlDocumentReader
> {
* The default constructor of this class.
*/
public ThingDescriptionReader() {
- super.setClassLoader(ThingDescriptionReader.class.getClassLoader());
+ ClassLoader classLoader = ThingDescriptionReader.class.getClassLoader();
+ if (classLoader != null) {
+ super.setClassLoader(classLoader);
+ }
}
@Override
diff --git a/bundles/org.openhab.core.thing.xml/src/test/java/org/openhab/core/thing/xml/internal/Example.java b/bundles/org.openhab.core.thing.xml/src/test/java/org/openhab/core/thing/xml/internal/Example.java
index 30393a13ac..ffaec3d2b8 100644
--- a/bundles/org.openhab.core.thing.xml/src/test/java/org/openhab/core/thing/xml/internal/Example.java
+++ b/bundles/org.openhab.core.thing.xml/src/test/java/org/openhab/core/thing/xml/internal/Example.java
@@ -12,8 +12,11 @@
*/
package org.openhab.core.thing.xml.internal;
+import static org.eclipse.jdt.annotation.Checks.requireNonNull;
+
import java.net.URL;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
/**
@@ -23,14 +26,15 @@ import org.junit.jupiter.api.Test;
*
* @author Michael Grammling - Initial contribution
*/
+@NonNullByDefault
public class Example {
- @SuppressWarnings("unchecked")
@Test
public void test() throws Exception {
- URL channelsURL = Example.class.getClassLoader().getResource("/example/example.xml");
+ ClassLoader classLoader = requireNonNull(Example.class.getClassLoader());
+ URL channelsURL = requireNonNull(classLoader.getResource("/example/example.xml"));
ThingDescriptionReader reader = new ThingDescriptionReader();
- ThingDescriptionList thingList = (ThingDescriptionList) reader.readFromXML(channelsURL);
+ reader.readFromXML(channelsURL);
}
}
diff --git a/bundles/org.openhab.core.thing/.classpath b/bundles/org.openhab.core.thing/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.thing/.classpath
+++ b/bundles/org.openhab.core.thing/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java
index a02e4d4058..e7bf94e97b 100644
--- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java
+++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java
@@ -1120,11 +1120,12 @@ public class ThingManagerImpl
}
private synchronized Lock getLockForThing(ThingUID thingUID) {
- if (thingLocks.get(thingUID) == null) {
- Lock lock = new ReentrantLock();
+ Lock lock = thingLocks.get(thingUID);
+ if (lock == null) {
+ lock = new ReentrantLock();
thingLocks.put(thingUID, lock);
}
- return thingLocks.get(thingUID);
+ return lock;
}
private ThingStatusInfo buildStatusInfo(ThingStatus thingStatus, ThingStatusDetail thingStatusDetail,
diff --git a/bundles/org.openhab.core.transform/.classpath b/bundles/org.openhab.core.transform/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.transform/.classpath
+++ b/bundles/org.openhab.core.transform/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.ui.icon/.classpath b/bundles/org.openhab.core.ui.icon/.classpath
index 3721ade03c..4244343f8a 100644
--- a/bundles/org.openhab.core.ui.icon/.classpath
+++ b/bundles/org.openhab.core.ui.icon/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.ui/.classpath b/bundles/org.openhab.core.ui/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.ui/.classpath
+++ b/bundles/org.openhab.core.ui/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java
index 7fd224eec1..66f49f5a2e 100644
--- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java
+++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java
@@ -35,12 +35,11 @@ public class UIComponentRegistryFactoryImpl implements UIComponentRegistryFactor
@Override
public UIComponentRegistryImpl getRegistry(String namespace) {
- if (registries.containsKey(namespace)) {
- return registries.get(namespace);
- } else {
- UIComponentRegistryImpl registry = new UIComponentRegistryImpl(namespace, storageService);
+ UIComponentRegistryImpl registry = registries.get(namespace);
+ if (registry == null) {
+ registry = new UIComponentRegistryImpl(namespace, storageService);
registries.put(namespace, registry);
- return registry;
}
+ return registry;
}
}
diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/tiles/TileService.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/tiles/TileService.java
index 4660a06384..a98f76be54 100644
--- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/tiles/TileService.java
+++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/tiles/TileService.java
@@ -19,6 +19,7 @@ import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.ui.tiles.ExternalServiceTile;
+import org.openhab.core.ui.tiles.ExternalServiceTile.TileBuilder;
import org.openhab.core.ui.tiles.Tile;
import org.openhab.core.ui.tiles.TileProvider;
import org.osgi.service.component.annotations.Activate;
@@ -75,18 +76,20 @@ public class TileService implements TileProvider {
// get prefix from link name
String linkname = key.substring(0, key.length() - LINK_NAME.length());
- String name = (String) properties.get(linkname + LINK_NAME);
- String url = (String) properties.get(linkname + LINK_URL);
- String imageUrl = (String) properties.get(linkname + LINK_IMAGEURL);
-
- Tile newTile = new ExternalServiceTile.TileBuilder().withName(name).withUrl(url)
- .withImageUrl(imageUrl).build();
+ String name = (String) properties.getOrDefault(linkname + LINK_NAME, "");
+ String url = (String) properties.getOrDefault(linkname + LINK_URL, "");
+ String imageUrl = (String) properties.getOrDefault(linkname + LINK_IMAGEURL, "");
if (!name.isEmpty() && !url.isEmpty()) {
+ TileBuilder builder = new ExternalServiceTile.TileBuilder().withName(name).withUrl(url);
+ if (!imageUrl.isEmpty()) {
+ builder = builder.withImageUrl(imageUrl);
+ }
+ Tile newTile = builder.build();
addTile(newTile);
logger.debug("Tile added: {}", newTile);
} else {
- logger.warn("Ignore invalid tile '{}': {}", linkname, newTile);
+ logger.warn("Ignore invalid tile '{}': {}", linkname, name);
}
}
}
diff --git a/bundles/org.openhab.core.voice/.classpath b/bundles/org.openhab.core.voice/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/bundles/org.openhab.core.voice/.classpath
+++ b/bundles/org.openhab.core.voice/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/bundles/org.openhab.core/.classpath b/bundles/org.openhab.core/.classpath
index eb21acf010..ef8eb9b150 100644
--- a/bundles/org.openhab.core/.classpath
+++ b/bundles/org.openhab.core/.classpath
@@ -9,11 +9,13 @@
+
+
@@ -28,10 +30,5 @@
-
-
-
-
-
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java
index b00e7cecde..03ab300ff7 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java
@@ -253,15 +253,14 @@ public class ByteArrayFileCache {
*/
File getUniqueFile(String key) {
String uniqueFileName = getUniqueFileName(key);
- if (filesInCache.containsKey(uniqueFileName)) {
- return filesInCache.get(uniqueFileName);
- } else {
+ File fileInCache = filesInCache.get(uniqueFileName);
+ if (fileInCache == null) {
String fileExtension = getFileExtension(key);
- File fileInCache = new File(cacheFolder,
+ fileInCache = new File(cacheFolder,
uniqueFileName + (fileExtension == null ? "" : EXTENSION_SEPARATOR + fileExtension));
filesInCache.put(uniqueFileName, fileInCache);
- return fileInCache;
}
+ return fileInCache;
}
/**
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java
index ff02ed5c4e..dd8ccae24b 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java
@@ -229,7 +229,7 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
@Override
public void removed(Provider provider, E element) {
- final E existingElement;
+ final @Nullable E existingElement;
elementWriteLock.lock();
try {
// The given "element" might not be the live instance but loaded from storage.
@@ -250,7 +250,10 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
}
identifierToElement.remove(uid);
elementToProvider.remove(existingElement);
- providerToElements.get(provider).remove(existingElement);
+ Collection providerElements = providerToElements.get(provider);
+ if (providerElements != null) {
+ providerElements.remove(existingElement);
+ }
elements.remove(existingElement);
} finally {
elementWriteLock.unlock();
@@ -273,7 +276,7 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
return;
}
- final E existingElement;
+ final @Nullable E existingElement;
elementWriteLock.lock();
try {
// The given "element" might not be the live instance but loaded from storage.
@@ -296,8 +299,10 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
elementToProvider.remove(existingElement);
elementToProvider.put(element, provider);
final Collection providerElements = providerToElements.get(provider);
- providerElements.remove(existingElement);
- providerElements.add(element);
+ if (providerElements != null) {
+ providerElements.remove(existingElement);
+ providerElements.add(element);
+ }
elements.remove(existingElement);
elements.add(element);
} finally {
@@ -325,8 +330,9 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
protected @Nullable Entry, E> getValueAndProvider(K key) {
elementReadLock.lock();
try {
- final E element = identifierToElement.get(key);
- return element == null ? null : Map.entry(elementToProvider.get(element), element);
+ final @Nullable E element = identifierToElement.get(key);
+ final Provider provider = elementToProvider.get(element);
+ return element == null || provider == null ? null : Map.entry(provider, element);
} finally {
elementReadLock.unlock();
}
@@ -433,11 +439,8 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN
protected @Nullable Provider getProvider(K key) {
elementReadLock.lock();
try {
- final E element = identifierToElement.get(key);
- if (element == null) {
- return null;
- }
- return elementToProvider.get(element);
+ final @Nullable E element = identifierToElement.get(key);
+ return element == null ? null : elementToProvider.get(element);
} finally {
elementReadLock.unlock();
}
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java
index 3bc9a2df67..5775302987 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java
@@ -89,17 +89,19 @@ abstract class AbstractInvocationHandler {
}
void handleExecutionException(Method method, ExecutionException e) {
- if (e.getCause() instanceof DuplicateExecutionException) {
- handleDuplicate(method, (DuplicateExecutionException) e.getCause());
- } else if (e.getCause() instanceof InvocationTargetException) {
- handleException(method, (InvocationTargetException) e.getCause());
+ Throwable cause = e.getCause();
+ if (cause instanceof DuplicateExecutionException) {
+ handleDuplicate(method, (DuplicateExecutionException) cause);
+ } else if (cause instanceof InvocationTargetException) {
+ handleException(method, (InvocationTargetException) cause);
}
}
void handleException(Method method, InvocationTargetException e) {
- logger.error(MSG_ERROR, toString(method), target, e.getCause().getMessage(), e.getCause());
+ Throwable cause = e.getCause();
+ logger.error(MSG_ERROR, toString(method), target, cause == null ? "" : cause.getMessage(), e.getCause());
if (exceptionHandler != null) {
- exceptionHandler.accept(e.getCause());
+ exceptionHandler.accept(cause == null ? e : cause);
}
}
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/CombinedClassLoader.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/CombinedClassLoader.java
index d8383f9119..c87ae92575 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/CombinedClassLoader.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/CombinedClassLoader.java
@@ -27,6 +27,8 @@ import java.util.Vector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,6 +37,7 @@ import org.slf4j.LoggerFactory;
*
* @author Markus Rathgeb - Initial contribution
*/
+@NonNullByDefault
public class CombinedClassLoader extends ClassLoader {
private final Logger logger = LoggerFactory.getLogger(CombinedClassLoader.class);
@@ -47,16 +50,19 @@ public class CombinedClassLoader extends ClassLoader {
public static CombinedClassLoader fromClasses(final ClassLoader parent, final Stream> delegateClasses) {
final Map>> cls = new HashMap<>();
delegateClasses.forEach(clazz -> {
- cls.compute(clazz.getClassLoader(), (k, v) -> {
- if (v == null) {
- final Set> set = new HashSet<>();
- set.add(clazz);
- return set;
- } else {
- v.add(clazz);
- return v;
- }
- });
+ ClassLoader classLoader = clazz.getClassLoader();
+ if (classLoader != null) {
+ cls.compute(classLoader, (k, v) -> {
+ if (v == null) {
+ final Set> set = new HashSet<>();
+ set.add(clazz);
+ return set;
+ } else {
+ v.add(clazz);
+ return v;
+ }
+ });
+ }
});
return new CombinedClassLoader(parent, cls);
}
@@ -78,7 +84,11 @@ public class CombinedClassLoader extends ClassLoader {
}
@Override
- protected Class> findClass(String name) throws ClassNotFoundException {
+ protected Class> findClass(@Nullable String name) throws ClassNotFoundException {
+ if (name == null) {
+ throw new ClassNotFoundException("Cannot load class with null name");
+ }
+
for (final Entry>> entry : delegateClassLoaders.entrySet()) {
try {
final Class> clazz = entry.getKey().loadClass(name);
@@ -89,11 +99,14 @@ public class CombinedClassLoader extends ClassLoader {
} catch (final ClassNotFoundException ex) {
}
}
- throw new ClassNotFoundException(name);
+ throw new ClassNotFoundException("Delegates cannot load class with name: " + name);
}
@Override
- protected URL findResource(String name) {
+ protected @Nullable URL findResource(@Nullable String name) {
+ if (name == null) {
+ return null;
+ }
// Try to get the resource from one of the delegate class loaders.
// Return the first found one.
// If no delegate class loader can get the resource, return null.
@@ -102,7 +115,10 @@ public class CombinedClassLoader extends ClassLoader {
}
@Override
- protected Enumeration findResources(String name) throws IOException {
+ protected Enumeration findResources(@Nullable String name) throws IOException {
+ if (name == null) {
+ return Collections.emptyEnumeration();
+ }
final Vector vector = new Vector<>();
for (final ClassLoader delegate : delegateClassLoaders.keySet()) {
final Enumeration enumeration = delegate.getResources(name);
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerAsync.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerAsync.java
index 6b571980f4..186db9999b 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerAsync.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerAsync.java
@@ -38,7 +38,7 @@ class InvocationHandlerAsync extends AbstractInvocationHandler implements
}
@Override
- public @Nullable Object invoke(@Nullable Object proxy, @Nullable Method method, Object @Nullable [] args)
+ public @Nullable Object invoke(Object proxy, @Nullable Method method, @Nullable Object @Nullable [] args)
throws Throwable {
if (method != null) {
try {
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerSync.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerSync.java
index f4377a7afb..86b297cbfc 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerSync.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/InvocationHandlerSync.java
@@ -45,7 +45,7 @@ public class InvocationHandlerSync extends AbstractInvocationHandler imple
}
@Override
- public @Nullable Object invoke(@Nullable Object proxy, @Nullable Method method, Object @Nullable [] args)
+ public @Nullable Object invoke(Object proxy, @Nullable Method method, @Nullable Object @Nullable [] args)
throws Throwable {
if (method != null) {
Invocation invocation = new Invocation(this, method, args);
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/SafeCallerBuilderImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/SafeCallerBuilderImpl.java
index e1dfac2738..e350f2d523 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/SafeCallerBuilderImpl.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/SafeCallerBuilderImpl.java
@@ -65,8 +65,13 @@ public class SafeCallerBuilderImpl implements SafeCallerBuilder {
handler = new InvocationHandlerSync<>(manager, target, identifier, timeout, exceptionHandler,
timeoutHandler);
}
+ ClassLoader classLoader = getClass().getClassLoader();
+ if (classLoader == null) {
+ throw new IllegalStateException(
+ "Cannot create proxy because '" + getClass().getName() + "' class loader is null");
+ }
return (T) Proxy.newProxyInstance(
- CombinedClassLoader.fromClasses(getClass().getClassLoader(),
+ CombinedClassLoader.fromClasses(classLoader,
Stream.concat(Stream.of(target.getClass()), Arrays.stream(interfaceTypes))),
interfaceTypes, handler);
});
diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java
index 0b45167588..69d1461f34 100644
--- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java
+++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java
@@ -74,21 +74,32 @@ public class MetadataStateDescriptionFragmentProvider implements StateDescriptio
if (metadata != null) {
try {
StateDescriptionFragmentBuilder builder = StateDescriptionFragmentBuilder.create();
- if (metadata.getConfiguration().containsKey("pattern")) {
- builder.withPattern((String) metadata.getConfiguration().get("pattern"));
+
+ Object pattern = metadata.getConfiguration().get("pattern");
+ if (pattern != null) {
+ builder.withPattern((String) pattern);
}
- if (metadata.getConfiguration().containsKey("min")) {
- builder.withMinimum(getBigDecimal(metadata.getConfiguration().get("min")));
+
+ Object min = metadata.getConfiguration().get("min");
+ if (min != null) {
+ builder.withMinimum(getBigDecimal(min));
}
- if (metadata.getConfiguration().containsKey("max")) {
- builder.withMaximum(getBigDecimal(metadata.getConfiguration().get("max")));
+
+ Object max = metadata.getConfiguration().get("max");
+ if (max != null) {
+ builder.withMaximum(getBigDecimal(max));
}
- if (metadata.getConfiguration().containsKey("step")) {
- builder.withStep(getBigDecimal(metadata.getConfiguration().get("step")));
+
+ Object step = metadata.getConfiguration().get("step");
+ if (step != null) {
+ builder.withStep(getBigDecimal(step));
}
- if (metadata.getConfiguration().containsKey("readOnly")) {
- builder.withReadOnly(getBoolean(metadata.getConfiguration().get("readOnly")));
+
+ Object readOnly = metadata.getConfiguration().get("readOnly");
+ if (readOnly != null) {
+ builder.withReadOnly(getBoolean(readOnly));
}
+
if (metadata.getConfiguration().containsKey("options")) {
List stateOptions = Stream
.of(metadata.getConfiguration().get("options").toString().split(",")).map(o -> {
diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/types/util/UnitUtilsTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/types/util/UnitUtilsTest.java
index f86b161784..3f7fc26140 100644
--- a/bundles/org.openhab.core/src/test/java/org/openhab/core/types/util/UnitUtilsTest.java
+++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/types/util/UnitUtilsTest.java
@@ -12,6 +12,7 @@
*/
package org.openhab.core.types.util;
+import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;
@@ -62,12 +63,10 @@ public class UnitUtilsTest {
@Test
public void whenValidDimensionIsGivenShouldCreateQuantityClass() {
- Class extends Quantity>> temperature = UnitUtils.parseDimension("Temperature");
- assertNotNull(temperature);
+ Class extends Quantity>> temperature = requireNonNull(UnitUtils.parseDimension("Temperature"));
assertTrue(Temperature.class.isAssignableFrom(temperature));
- Class extends Quantity>> intensity = UnitUtils.parseDimension("Intensity");
- assertNotNull(intensity);
+ Class extends Quantity>> intensity = requireNonNull(UnitUtils.parseDimension("Intensity"));
assertTrue(Intensity.class.isAssignableFrom(intensity));
}
diff --git a/bundles/pom.xml b/bundles/pom.xml
index 43cbb11d2a..bb45762c7b 100644
--- a/bundles/pom.xml
+++ b/bundles/pom.xml
@@ -103,6 +103,10 @@
org.openhab.core.ui.icon
+
+ target/dependency
+
+
org.openhab.core.bom
@@ -149,6 +153,29 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.1.1
+
+
+ unpack-eea
+
+ unpack
+
+
+
+
+ org.lastnpe.eea
+ eea-all
+ 2.1.0
+ true
+
+
+
+
+
+
diff --git a/itests/org.openhab.core.auth.oauth2client.tests/.classpath b/itests/org.openhab.core.auth.oauth2client.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.auth.oauth2client.tests/.classpath
+++ b/itests/org.openhab.core.auth.oauth2client.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.automation.integration.tests/.classpath b/itests/org.openhab.core.automation.integration.tests/.classpath
index 6938cf0e5c..0291b82e45 100644
--- a/itests/org.openhab.core.automation.integration.tests/.classpath
+++ b/itests/org.openhab.core.automation.integration.tests/.classpath
@@ -14,11 +14,13 @@
+
+
diff --git a/itests/org.openhab.core.automation.module.core.tests/.classpath b/itests/org.openhab.core.automation.module.core.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.automation.module.core.tests/.classpath
+++ b/itests/org.openhab.core.automation.module.core.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.automation.module.script.tests/.classpath b/itests/org.openhab.core.automation.module.script.tests/.classpath
index 234db15be4..6c969470df 100644
--- a/itests/org.openhab.core.automation.module.script.tests/.classpath
+++ b/itests/org.openhab.core.automation.module.script.tests/.classpath
@@ -21,11 +21,13 @@
+
+
diff --git a/itests/org.openhab.core.automation.module.timer.tests/.classpath b/itests/org.openhab.core.automation.module.timer.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.automation.module.timer.tests/.classpath
+++ b/itests/org.openhab.core.automation.module.timer.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.automation.tests/.classpath b/itests/org.openhab.core.automation.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.automation.tests/.classpath
+++ b/itests/org.openhab.core.automation.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.binding.xml.tests/.classpath b/itests/org.openhab.core.binding.xml.tests/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/itests/org.openhab.core.binding.xml.tests/.classpath
+++ b/itests/org.openhab.core.binding.xml.tests/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/itests/org.openhab.core.config.core.tests/.classpath b/itests/org.openhab.core.config.core.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.config.core.tests/.classpath
+++ b/itests/org.openhab.core.config.core.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.discovery.mdns.tests/.classpath b/itests/org.openhab.core.config.discovery.mdns.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.config.discovery.mdns.tests/.classpath
+++ b/itests/org.openhab.core.config.discovery.mdns.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.discovery.tests/.classpath b/itests/org.openhab.core.config.discovery.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.config.discovery.tests/.classpath
+++ b/itests/org.openhab.core.config.discovery.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/.classpath b/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/.classpath
+++ b/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.discovery.usbserial.tests/.classpath b/itests/org.openhab.core.config.discovery.usbserial.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.config.discovery.usbserial.tests/.classpath
+++ b/itests/org.openhab.core.config.discovery.usbserial.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.dispatch.tests/.classpath b/itests/org.openhab.core.config.dispatch.tests/.classpath
index c34b29307c..d5a8e32c52 100644
--- a/itests/org.openhab.core.config.dispatch.tests/.classpath
+++ b/itests/org.openhab.core.config.dispatch.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.config.xml.tests/.classpath b/itests/org.openhab.core.config.xml.tests/.classpath
index c34b29307c..d5a8e32c52 100644
--- a/itests/org.openhab.core.config.xml.tests/.classpath
+++ b/itests/org.openhab.core.config.xml.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.ephemeris.tests/.classpath b/itests/org.openhab.core.ephemeris.tests/.classpath
index 4559ca0b25..600c3686ed 100644
--- a/itests/org.openhab.core.ephemeris.tests/.classpath
+++ b/itests/org.openhab.core.ephemeris.tests/.classpath
@@ -16,9 +16,16 @@
+
+
+
+
+
+
+
diff --git a/itests/org.openhab.core.io.rest.core.tests/.classpath b/itests/org.openhab.core.io.rest.core.tests/.classpath
index 3721ade03c..4244343f8a 100644
--- a/itests/org.openhab.core.io.rest.core.tests/.classpath
+++ b/itests/org.openhab.core.io.rest.core.tests/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/itests/org.openhab.core.model.core.tests/.classpath b/itests/org.openhab.core.model.core.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.model.core.tests/.classpath
+++ b/itests/org.openhab.core.model.core.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.model.item.tests/.classpath b/itests/org.openhab.core.model.item.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.model.item.tests/.classpath
+++ b/itests/org.openhab.core.model.item.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.model.rule.tests/.classpath b/itests/org.openhab.core.model.rule.tests/.classpath
index 3721ade03c..4244343f8a 100644
--- a/itests/org.openhab.core.model.rule.tests/.classpath
+++ b/itests/org.openhab.core.model.rule.tests/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/itests/org.openhab.core.model.script.tests/.classpath b/itests/org.openhab.core.model.script.tests/.classpath
index f87555141c..4d0b04e459 100644
--- a/itests/org.openhab.core.model.script.tests/.classpath
+++ b/itests/org.openhab.core.model.script.tests/.classpath
@@ -15,13 +15,14 @@
-
+
+
diff --git a/itests/org.openhab.core.model.thing.tests/.classpath b/itests/org.openhab.core.model.thing.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.model.thing.tests/.classpath
+++ b/itests/org.openhab.core.model.thing.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.model.thing.testsupport/.classpath b/itests/org.openhab.core.model.thing.testsupport/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.model.thing.testsupport/.classpath
+++ b/itests/org.openhab.core.model.thing.testsupport/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.storage.json.tests/.classpath b/itests/org.openhab.core.storage.json.tests/.classpath
index 4559ca0b25..405456d1da 100644
--- a/itests/org.openhab.core.storage.json.tests/.classpath
+++ b/itests/org.openhab.core.storage.json.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.tests/.classpath b/itests/org.openhab.core.tests/.classpath
index c34b29307c..d5a8e32c52 100644
--- a/itests/org.openhab.core.tests/.classpath
+++ b/itests/org.openhab.core.tests/.classpath
@@ -16,11 +16,13 @@
+
+
diff --git a/itests/org.openhab.core.thing.tests/.classpath b/itests/org.openhab.core.thing.tests/.classpath
index 234db15be4..6c969470df 100644
--- a/itests/org.openhab.core.thing.tests/.classpath
+++ b/itests/org.openhab.core.thing.tests/.classpath
@@ -21,11 +21,13 @@
+
+
diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java
index ffbe716674..4c36b9a09c 100644
--- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java
+++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java
@@ -147,13 +147,15 @@ public class FirmwareUpdateServiceFirmwareRestrictionTest extends JavaOSGiTest {
registerService(createFirmwareUpdateHandler(hwVersionTwoHighFwVersionThing));
// Define restrictions for the hardware versions
- FirmwareRestriction hwVersion1Restriction = thg -> Integer
- .parseInt(thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION)) < 14
- || FW_VERSION_32.equals(thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION));
+ FirmwareRestriction hwVersion1Restriction = thg -> {
+ String version = thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION);
+ return version != null && (Integer.parseInt(version) < 14 || FW_VERSION_32.equals(version));
+ };
- FirmwareRestriction hwVersion2Restriction = thg -> Integer
- .parseInt(thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION)) >= 14
- && !FW_VERSION_32.equals(thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION));
+ FirmwareRestriction hwVersion2Restriction = thg -> {
+ String version = thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION);
+ return version != null && (Integer.parseInt(version) >= 14 && !FW_VERSION_32.equals(version));
+ };
// Build firmwares
Firmware fw38 = FirmwareBuilder.create(thingTypeUID, FW_VERSION_38)
diff --git a/itests/org.openhab.core.thing.xml.tests/.classpath b/itests/org.openhab.core.thing.xml.tests/.classpath
index 15a6560a73..ef8eb9b150 100644
--- a/itests/org.openhab.core.thing.xml.tests/.classpath
+++ b/itests/org.openhab.core.thing.xml.tests/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/itests/org.openhab.core.voice.tests/.classpath b/itests/org.openhab.core.voice.tests/.classpath
index 3721ade03c..4244343f8a 100644
--- a/itests/org.openhab.core.voice.tests/.classpath
+++ b/itests/org.openhab.core.voice.tests/.classpath
@@ -9,11 +9,13 @@
+
+
diff --git a/itests/pom.xml b/itests/pom.xml
index 666ab9a042..698f06a42b 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -48,6 +48,7 @@
true
true
+ target/dependency
@@ -86,6 +87,29 @@
biz.aQute.bnd
bnd-maven-plugin
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.1.1
+
+
+ unpack-eea
+
+ unpack
+
+
+
+
+ org.lastnpe.eea
+ eea-all
+ 2.1.0
+ true
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index b89650b6a0..9fcd97afd7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -270,8 +270,12 @@ Import-Package: \\
3.8.1
eclipse
+
+ CLASSPATH
+ ${project.build.directory}/dependency
+
- -err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,-nullUncheckedConversion
+ -err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion
-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference
true