[FELIX-4457]org.apache.felix.utils.properties will save key=value on top of comments if the original properties file are all comments
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1577060 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/utils/src/main/java/org/apache/felix/utils/properties/Properties.java b/utils/src/main/java/org/apache/felix/utils/properties/Properties.java
index 81817aa..30fb4df 100644
--- a/utils/src/main/java/org/apache/felix/utils/properties/Properties.java
+++ b/utils/src/main/java/org/apache/felix/utils/properties/Properties.java
@@ -350,8 +350,10 @@
protected void loadLayout(Reader in) throws IOException
{
PropertiesReader reader = new PropertiesReader(in);
+ boolean hasProperty = false;
while (reader.nextProperty())
{
+ hasProperty = true;
storage.put(reader.getPropertyName(), reader.getPropertyValue());
int idx = checkHeaderComment(reader.getCommentLines());
layout.put(reader.getPropertyName(),
@@ -360,7 +362,11 @@
null,
new ArrayList<String>(reader.getValueLines())));
}
- footer = new ArrayList<String>(reader.getCommentLines());
+ if (hasProperty) {
+ footer = new ArrayList<String>(reader.getCommentLines());
+ } else {
+ header = new ArrayList<String>(reader.getCommentLines());
+ }
if (substitute)
{
substitute();
@@ -1099,4 +1105,4 @@
} // class Layout
-}
\ No newline at end of file
+}