Commit d72e319dff3bcf57c3f7a85d855ab333ccaf67e2
1 parent
fffba4d1
Exists in
master
Tratando erro de conversão de tipos
Showing
1 changed file
with
14 additions
and
1 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationPrimitiveOrWrapperValueExtractor.java
... | ... | @@ -43,6 +43,8 @@ import java.util.HashSet; |
43 | 43 | import java.util.Set; |
44 | 44 | |
45 | 45 | import org.apache.commons.configuration.Configuration; |
46 | +import org.apache.commons.configuration.ConfigurationException; | |
47 | +import org.apache.commons.configuration.ConversionException; | |
46 | 48 | import org.apache.commons.configuration.DataConfiguration; |
47 | 49 | import org.apache.commons.lang.ClassUtils; |
48 | 50 | |
... | ... | @@ -69,7 +71,18 @@ public class ConfigurationPrimitiveOrWrapperValueExtractor implements Configurat |
69 | 71 | @Override |
70 | 72 | @SuppressWarnings("unchecked") |
71 | 73 | public Object getValue(String prefix, String key, Field field, Configuration configuration) { |
72 | - return new DataConfiguration(configuration).get(ClassUtils.primitiveToWrapper(field.getType()), prefix + key); | |
74 | + Object value; | |
75 | + try { | |
76 | + value = new DataConfiguration(configuration).get(ClassUtils.primitiveToWrapper(field.getType()), prefix | |
77 | + + key); | |
78 | + } catch (ConversionException e) { | |
79 | + value = new DataConfiguration(configuration).get(ClassUtils.primitiveToWrapper(String.class), prefix + key); | |
80 | + if (value.equals("")) { | |
81 | + value = null; | |
82 | + } else | |
83 | + throw e; | |
84 | + } | |
85 | + return value; | |
73 | 86 | } |
74 | 87 | |
75 | 88 | @Override | ... | ... |