mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 17:47:41 +01:00
Fixes lookup of default configuration values for nested paths (#2322)
The lookup of default configuration values with multiple path segments failed with a class cast exception because the full path was treated as a new configuration section instead of only the root.
This commit is contained in:
parent
050d935891
commit
6b7046c8b7
@ -56,7 +56,7 @@ public final class Configuration
|
||||
Object section = self.get( root );
|
||||
if ( section == null )
|
||||
{
|
||||
section = new Configuration( ( defaults == null ) ? null : defaults.getSection( path ) );
|
||||
section = new Configuration( ( defaults == null ) ? null : defaults.getSection( root ) );
|
||||
self.put( root, section );
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package net.md_5.bungee.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DefaultConfigurationTest
|
||||
{
|
||||
@Test
|
||||
public void testDefaultValues()
|
||||
{
|
||||
Configuration defaultConfig = new Configuration();
|
||||
defaultConfig.set( "setting", 10 );
|
||||
defaultConfig.set( "nested.setting", 11 );
|
||||
defaultConfig.set( "double.nested.setting", 12 );
|
||||
|
||||
Configuration actualConfig = new Configuration( defaultConfig );
|
||||
|
||||
Assert.assertEquals( 10, actualConfig.getInt( "setting" ) );
|
||||
Assert.assertEquals( 11, actualConfig.getInt( "nested.setting" ) );
|
||||
Assert.assertEquals( 12, actualConfig.getInt( "double.nested.setting" ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user