File tree 2 files changed +16
-1
lines changed
main/java/org/springframework/boot/bind
test/java/org/springframework/boot/bind
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 45
45
*
46
46
* @author Dave Syer
47
47
* @author Phillip Webb
48
+ * @author Stephane Nicoll
48
49
* @see RelaxedNames
49
50
*/
50
51
public class RelaxedDataBinder extends DataBinder {
@@ -73,7 +74,14 @@ public RelaxedDataBinder(Object target) {
73
74
public RelaxedDataBinder (Object target , String namePrefix ) {
74
75
super (wrapTarget (target ), (StringUtils .hasLength (namePrefix ) ? namePrefix
75
76
: DEFAULT_OBJECT_NAME ));
76
- this .namePrefix = (StringUtils .hasLength (namePrefix ) ? namePrefix + "." : null );
77
+ this .namePrefix = cleanNamePrefix (namePrefix );
78
+ }
79
+
80
+ private static String cleanNamePrefix (String namePrefix ) {
81
+ if (!StringUtils .hasLength (namePrefix )) {
82
+ return null ;
83
+ }
84
+ return (namePrefix .endsWith ("." ) ? namePrefix : namePrefix + "." );
77
85
}
78
86
79
87
/**
Original file line number Diff line number Diff line change @@ -95,6 +95,13 @@ public void testBindStringWithPrefix() throws Exception {
95
95
assertEquals ("bar" , target .getFoo ());
96
96
}
97
97
98
+ @ Test
99
+ public void testBindStringWithPrefixDotSuffix () throws Exception {
100
+ VanillaTarget target = new VanillaTarget ();
101
+ bind (target , "some.test.foo: bar" , "some.test." );
102
+ assertEquals ("bar" , target .getFoo ());
103
+ }
104
+
98
105
@ Test
99
106
public void testBindFromEnvironmentStyleWithPrefix () throws Exception {
100
107
VanillaTarget target = new VanillaTarget ();
You can’t perform that action at this time.
0 commit comments