Fix issue with multiline comment in OSGI properties
If a component property as a multiline comment the app activation
will throw an exception and no property for that component would be initialized.
This patch address that in two ways:
- Make sure that if we cannot parse a line from cfgdef the other properties are enabled and logs a warn.
- Changes the onos-maven-plugin so that it removes new lines when generating the .cfgdef file
Bumping version as plugin is already published from onos-2.5 branch
Change-Id: I550c23624118782fe6d79c9abbaf75ae59ea0eab
diff --git a/core/net/src/main/java/org/onosproject/cfg/impl/ConfigPropertyDefinitions.java b/core/net/src/main/java/org/onosproject/cfg/impl/ConfigPropertyDefinitions.java
index e07773b..25ba6e0 100644
--- a/core/net/src/main/java/org/onosproject/cfg/impl/ConfigPropertyDefinitions.java
+++ b/core/net/src/main/java/org/onosproject/cfg/impl/ConfigPropertyDefinitions.java
@@ -75,6 +75,11 @@
while ((line = br.readLine()) != null) {
if (!line.isEmpty() && !line.startsWith(COMMENT)) {
String[] f = line.split(SEP, 4);
+ if (f.length < 4) {
+ log.warn("Cannot parse property from line: '{}'. " +
+ "This property will be ignored", line);
+ continue;
+ }
builder.add(defineProperty(f[0], Type.valueOf(f[1]), f[2], f[3]));
}
}
diff --git a/tools/package/maven-plugin/pom.xml b/tools/package/maven-plugin/pom.xml
index 488c806..8b2da91 100644
--- a/tools/package/maven-plugin/pom.xml
+++ b/tools/package/maven-plugin/pom.xml
@@ -26,7 +26,7 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
- <version>2.4-SNAPSHOT</version>
+ <version>2.5.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<description>Maven plugin for packaging ONOS applications or generating
diff --git a/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java b/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
index 60d5f63..4397357 100644
--- a/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
+++ b/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
@@ -174,7 +174,11 @@
}
JavaField field = javaClass.getFieldByName(name);
if (field != null) {
+ // make sure that the new lines are removed from the comment, they will break the property loading.
String comment = field.getComment();
+ if (comment != null) {
+ comment = comment.replace("\n", " ").replace("\r", " ");
+ }
return comment != null ? comment : NO_DESCRIPTION;
}
throw new IllegalStateException("cfgdef could not find a variable named " + name + " in " + javaClass.getName());