Author: ffang Date: Thu Mar 13 08:19:18 2014 New Revision: 1577060 URL: http://svn.apache.org/r1577060 Log: [FELIX-4457]org.apache.felix.utils.properties will save key=value on top of comments if the original properties file are all comments
Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/Properties.java Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/Properties.java URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/Properties.java?rev=1577060&r1=1577059&r2=1577060&view=diff ============================================================================== --- felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/Properties.java (original) +++ felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/Properties.java Thu Mar 13 08:19:18 2014 @@ -350,8 +350,10 @@ public class Properties extends Abstract 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 @@ public class Properties extends Abstract 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 @@ public class Properties extends Abstract } // class Layout -} \ No newline at end of file +}