Fix #3313: Not all activities are captured in service activity feed (#3339)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-03-12 09:48:06 -08:00 committed by GitHub
parent 369b8c3b31
commit 170cb529ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -257,6 +257,11 @@ public final class ChangeEventParser {
} }
private static String getUpdateMessage(String updatedField, Object oldValue, Object newValue) { private static String getUpdateMessage(String updatedField, Object oldValue, Object newValue) {
// New value should not be null in any case for an update
if (newValue == null) {
return StringUtils.EMPTY;
}
if (oldValue == null || oldValue.toString().isEmpty()) { if (oldValue == null || oldValue.toString().isEmpty()) {
return String.format("Updated **%s** to %s", updatedField, getFieldValue(newValue)); return String.format("Updated **%s** to %s", updatedField, getFieldValue(newValue));
} else if (updatedField.contains("tags") || updatedField.contains("owner")) { } else if (updatedField.contains("tags") || updatedField.contains("owner")) {
@ -265,6 +270,7 @@ public final class ChangeEventParser {
// if old value is not empty, and is of type array or object, the updates can be across multiple keys // if old value is not empty, and is of type array or object, the updates can be across multiple keys
// Example: [{name: "col1", dataType: "varchar", dataLength: "20"}] // Example: [{name: "col1", dataType: "varchar", dataLength: "20"}]
if (!newValue.toString().isEmpty()) {
try { try {
// Check if field value is a json string // Check if field value is a json string
JsonValue newJson = JsonUtils.readJson(newValue.toString()); JsonValue newJson = JsonUtils.readJson(newValue.toString());
@ -292,10 +298,11 @@ public final class ChangeEventParser {
return getObjectUpdateMessage(updatedField, oldJsonObject, newJsonObject); return getObjectUpdateMessage(updatedField, oldJsonObject, newJsonObject);
} }
} catch (JsonParsingException ex) { } catch (JsonParsingException ex) {
// update is of String type // update is of type String
return getPlainTextUpdateMessage(updatedField, oldValue.toString(), newValue.toString()); // ignore this exception and process update message for plain text
} }
return StringUtils.EMPTY; }
return getPlainTextUpdateMessage(updatedField, oldValue.toString(), newValue.toString());
} }
private static String getPlaintextDiff(String oldValue, String newValue) { private static String getPlaintextDiff(String oldValue, String newValue) {