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