Skip to content

Commit 9d28349

Browse files
committed
Francis Charpin reported that whitespace between the equals sign was leading to errors. I don't recall if there was a reason for not supporting that, so adding a test for this along with Francis' fix to trim the key/value in the custom properties file.
1 parent bb647d6 commit 9d28349

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

simple-jndi/src/java/org/osjava/sj/loader/util/CustomProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public synchronized void load(InputStream in) throws IOException {
6767
// split equals sign
6868
idx = line.indexOf('=');
6969
if(idx != -1) {
70-
this.setProperty(line.substring(0,idx), line.substring(idx+1));
70+
this.setProperty(line.substring(0,idx).trim(), line.substring(idx+1).trim());
7171
} else {
7272
// blank line, or just a bad line
7373
// we ignore it

simple-jndi/src/test/config/default.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ com.genjava=Foo
22
name=Henri
33
url=yandell.org
44
name=Fred
5+
withspace = Check

simple-jndi/src/test/org/osjava/sj/loader/JndiLoaderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003-2005, Henri Yandell
2+
* Copyright (c) 2003-2013, Henri Yandell
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or
@@ -132,6 +132,7 @@ public void testDefaultFile() {
132132
assertEquals( "Henri", list.get(0) );
133133
assertEquals( "Fred", list.get(1) );
134134
assertEquals( "Foo", ctxt.lookup("com.genjava") );
135+
assertEquals( "Check", ctxt.lookup("withspace") );
135136
} catch(IOException ioe) {
136137
ioe.printStackTrace();
137138
fail("IOException: "+ioe.getMessage());

0 commit comments

Comments
 (0)