Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed issue #71
  • Loading branch information
Luigi R. Viggiano committed Feb 25, 2014
1 parent 20c903b commit 403e979
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions owner/src/main/java/org/aeonbits/owner/Converters.java
Expand Up @@ -146,8 +146,12 @@ Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
PropertyEditor editor = PropertyEditorManager.findEditor(targetType);
if (editor == null) return null;
editor.setAsText(text);
return editor.getValue();
try {
editor.setAsText(text);
return editor.getValue();
} catch (Exception e) {
throw unsupportedConversion(targetType, text);
}
}
},

Expand Down
Expand Up @@ -34,8 +34,11 @@ public static interface PrimitiveTypesConfig extends Config {

@DefaultValue("7")
Integer daysInWeek();

@DefaultValue("invalid")
Integer invalid();
}

@Test
public void testDefaultIntValue() {
PrimitiveTypesConfig config = ConfigFactory.create(PrimitiveTypesConfig.class);
Expand Down Expand Up @@ -66,4 +69,10 @@ public void testDefaultIntegerValue() {
assertEquals(new Integer(7), config.daysInWeek());
}

@Test(expected = UnsupportedOperationException.class)
public void testInvalid() {
PrimitiveTypesConfig config = ConfigFactory.create(PrimitiveTypesConfig.class);
config.invalid();
}

}

0 comments on commit 403e979

Please sign in to comment.