#1938: Better handling of null config keys
This commit is contained in:
parent
37b3cb4a30
commit
11c7b246e0
@ -32,7 +32,7 @@ public final class Configuration
|
||||
|
||||
for ( Map.Entry<?, ?> entry : map.entrySet() )
|
||||
{
|
||||
String key = entry.getKey().toString();
|
||||
String key = ( entry.getKey() == null ) ? "null" : entry.getKey().toString();
|
||||
|
||||
if ( entry.getValue() instanceof Map )
|
||||
{
|
||||
|
@ -49,6 +49,10 @@ public class YamlConfigurationTest
|
||||
+ " 2: 2\n"
|
||||
+ " 3: 3\n"
|
||||
+ " 4: 4";
|
||||
private static final String NULL_TEST = ""
|
||||
+ "null:\n"
|
||||
+ " null: object\n"
|
||||
+ " object: null\n";
|
||||
|
||||
@Test
|
||||
public void testConfig() throws Exception
|
||||
@ -103,4 +107,16 @@ public class YamlConfigurationTest
|
||||
// empty
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNull()
|
||||
{
|
||||
Configuration conf = ConfigurationProvider.getProvider( YamlConfiguration.class ).load( NULL_TEST );
|
||||
|
||||
Assert.assertEquals( "object", conf.get( "null.null" ) );
|
||||
Assert.assertEquals( "object", conf.getSection( "null" ).get( "null" ) );
|
||||
|
||||
Assert.assertEquals( null, conf.get( "null.object" ) );
|
||||
Assert.assertEquals( "", conf.getString( "null.object" ) );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user