Accounted for uninitialized fields

This commit is contained in:
Nick Goupinets 2021-05-21 12:00:01 -04:00
parent e243674f5d
commit d0d0ff9890
1 changed files with 12 additions and 8 deletions

View File

@ -538,14 +538,14 @@ public final class TerserUtil {
IBase newFieldValue = childDefinition.getChildByName(childDefinition.getElementName()).newInstance();
if (theFromFieldValue instanceof IPrimitiveType) {
try {
Method copyMethod = getMethod(theFromFieldValue, "copy");
if (copyMethod != null) {
newFieldValue = (IBase) copyMethod.invoke(theFromFieldValue, new Object[]{});
}
} catch (Throwable t) {
((IPrimitiveType) newFieldValue).setValueAsString(((IPrimitiveType) theFromFieldValue).getValueAsString());
try {
Method copyMethod = getMethod(theFromFieldValue, "copy");
if (copyMethod != null) {
newFieldValue = (IBase) copyMethod.invoke(theFromFieldValue, new Object[]{});
}
} catch (Throwable t) {
((IPrimitiveType) newFieldValue).setValueAsString(((IPrimitiveType) theFromFieldValue).getValueAsString());
}
} else {
theTerser.cloneInto(theFromFieldValue, newFieldValue, true);
}
@ -636,7 +636,11 @@ public final class TerserUtil {
return;
}
values.clear();
try {
values.clear();
} catch (Throwable t) {
ourLog.warn("Unable to clear values " + String.valueOf(values), t);
}
}
}