Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1) Handling NPE
  • Loading branch information
sjoshid authored and sjoshid committed May 10, 2020
1 parent 1d1bdea commit 0db6460
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main/java/org/influxdb/impl/InfluxDBResultMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@ <T> void setFieldValue(final T object, final Field field, final Method fieldSett
if (!field.isAccessible()) {
field.setAccessible(true);
}
if (!fieldSetter.isAccessible()) {
fieldSetter.setAccessible(true);
}
if (assignInstant(fieldType, field, fieldSetter, object, value, precision)
|| assignString(fieldType, field, fieldSetter, object, value)
|| assignDouble(fieldType, field, fieldSetter, object, value)
Expand Down Expand Up @@ -370,7 +367,7 @@ <T> boolean assignInstant(final Class<?> fieldType, final Field field, final Met
} else {
throw new InfluxDBMapperException("Unsupported type " + field.getClass() + " for field " + field.getName());
}
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, instant);
isInstantAssigned = true;
} else {
Expand All @@ -385,7 +382,7 @@ <T> boolean assignString(final Class<?> fieldType, final Field field, final Meth
boolean isStringAssigned = false;
if(String.class.isAssignableFrom(fieldType)) {
final String stringValue = String.valueOf(value);
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, stringValue);
isStringAssigned = true;
} else {
Expand All @@ -399,7 +396,7 @@ <T> boolean assignString(final Class<?> fieldType, final Field field, final Meth
<T> boolean assignDouble(final Class<?> fieldType, final Field field, final Method fieldSetter, final T object, final Object value) throws InvocationTargetException, IllegalAccessException {
boolean isDoubleAssigned = false;
if(double.class.isAssignableFrom(fieldType) || Double.class.isAssignableFrom(fieldType)) {
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, value);
isDoubleAssigned = true;
} else if(double.class.isAssignableFrom(fieldType)) {
Expand All @@ -418,7 +415,7 @@ <T> boolean assignLong(final Class<?> fieldType, final Field field, final Method
boolean isLongAssigned = false;
if(long.class.isAssignableFrom(fieldType) || Long.class.isAssignableFrom(fieldType)) {
final long longValue = ((Double) value).longValue();
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, longValue);
isLongAssigned = true;
} else if(long.class.isAssignableFrom(fieldType)) {
Expand All @@ -436,7 +433,7 @@ <T> boolean assignInteger(final Class<?> fieldType, final Field field, final Met
boolean isIntegerAssigned = false;
if(int.class.isAssignableFrom(fieldType) || Integer.class.isAssignableFrom(fieldType)) {
final int intValue = ((Double) value).intValue();
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, intValue);
isIntegerAssigned = true;
} else if(int.class.isAssignableFrom(fieldType)) {
Expand All @@ -454,7 +451,7 @@ <T> boolean assignBoolean(final Class<?> fieldType, final Field field, final Met
boolean isBooleanAssigned = false;
if(boolean.class.isAssignableFrom(fieldType) || Boolean.class.isAssignableFrom(fieldType)) {
final boolean boolValue = Boolean.parseBoolean(String.valueOf(value));
if(fieldSetter != null && fieldSetter.isAccessible()) {
if(fieldSetter != null) {
fieldSetter.invoke(object, boolValue);
isBooleanAssigned = true;
} else if(boolean.class.isAssignableFrom(fieldType)) {
Expand Down

0 comments on commit 0db6460

Please sign in to comment.