Skip to content

Commit 30318c5

Browse files
committed
Fix the NullPointerException on using the convertTo in Converter
1 parent a6baec5 commit 30318c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/main/java/io/ermdev/mapfierj/Converter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public <T> T convertTo(final Object o, Class<T> type) throws MappingException {
9797
.get();
9898

9999
objects.setObject(adapter.convert(o));
100-
if (!objects.getObject().getClass().equals(type)) {
100+
if (objects.getObject() == null || !objects.getObject().getClass().equals(type)) {
101101
throw new TypeException("Type not match");
102102
}
103103
return true;
@@ -111,7 +111,8 @@ public <T> T convertTo(final Object o, Class<T> type) throws MappingException {
111111
"with no arguments");
112112
}
113113
objects.setObject(adapter.convert(o));
114-
if (!objects.getObject().getClass().equals(type)) {
114+
if (objects.getObject() == null || !objects
115+
.getObject().getClass().equals(type)) {
115116
throw new TypeException("Type not match");
116117
}
117118
return true;

0 commit comments

Comments
 (0)