Skip to content

Commit

Permalink
Merge pull request #742 from tulikabhatt/fix_boolean_decoder
Browse files Browse the repository at this point in the history
Remove trailing/leading whitespace in boolean decoder
  • Loading branch information
rgallardo-netflix authored Jan 27, 2025
2 parents 56adbe4 + 6c71747 commit 9ca8b2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class DefaultTypeConverterFactory implements TypeConverter.Factory
public static final DefaultTypeConverterFactory INSTANCE = new DefaultTypeConverterFactory();

private static Boolean convertBoolean(String value) {
value = value.trim();
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("on")) {
return Boolean.TRUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,11 @@ public void testTypeConverterRegistry() {
class Foo {}
assertFalse(DefaultDecoder.INSTANCE.get(Foo.class).isPresent());
}

@Test
public void testConvertBoolean() {
DefaultDecoder decoder = DefaultDecoder.INSTANCE;
boolean flag = decoder.decode(boolean.class, " true ");
assertTrue(flag);
}
}

0 comments on commit 9ca8b2f

Please sign in to comment.