Fix Config.fromText to not skip a last line with no newline
Change-Id: Id6da6ff19296410806282bb7419fd8455e8c5475
This commit is contained in:
parent
3a4ebc0c24
commit
51d0e1f26e
|
@ -556,6 +556,15 @@ public void testQuotingForSubSectionNames() {
|
|||
assertEquals(result, config.toText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoFinalNewline() throws ConfigInvalidException {
|
||||
Config c = parse("[a]\n"
|
||||
+ "x = 0\n"
|
||||
+ "y = 1");
|
||||
assertEquals("0", c.getString("a", null, "x"));
|
||||
assertEquals("1", c.getString("a", null, "y"));
|
||||
}
|
||||
|
||||
private static void assertReadLong(long exp) throws ConfigInvalidException {
|
||||
assertReadLong(exp, String.valueOf(exp));
|
||||
}
|
||||
|
|
|
@ -1002,8 +1002,11 @@ public void fromText(final String text) throws ConfigInvalidException {
|
|||
ConfigLine e = new ConfigLine();
|
||||
for (;;) {
|
||||
int input = in.read();
|
||||
if (-1 == input)
|
||||
if (-1 == input) {
|
||||
if (e.section != null)
|
||||
newEntries.add(e);
|
||||
break;
|
||||
}
|
||||
|
||||
final char c = (char) input;
|
||||
if ('\n' == c) {
|
||||
|
|
Loading…
Reference in New Issue