ATLAS-2933:Empty array attributes are returned as null instead of an empty list#29
Closed
mahaha000 wants to merge 1 commit intoapache:masterfrom
Closed
ATLAS-2933:Empty array attributes are returned as null instead of an empty list#29mahaha000 wants to merge 1 commit intoapache:masterfrom
mahaha000 wants to merge 1 commit intoapache:masterfrom
Conversation
mneethiraj
reviewed
Mar 12, 2019
| @@ -207,12 +207,15 @@ public static <T extends AtlasElement> void setProperty(T element, String proper | |||
| Object existingValue = element.getProperty(propertyName, Object.class); | |||
|
|
|||
| if (value == null || (value instanceof Collection && ((Collection)value).isEmpty())) { | |||
Contributor
There was a problem hiding this comment.
Consider the following alternate, for easier readability:
if (value == null) {
if (existingValue != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Removing property {} from {}", propertyName, toString(element));
}
element.removeProperty(propertyName);
}
} else {
element.setProperty(propertyName, value);
}
mneethiraj
reviewed
Mar 12, 2019
| return softRefVal; | ||
| } | ||
|
|
||
| if (CollectionUtils.isNotEmpty(softRefVal)) { |
Contributor
There was a problem hiding this comment.
replace line #732 with: "else {", as the reverse condition is already tested in line #728 above.
mneethiraj
reviewed
Mar 14, 2019
| complexEntity.setAttribute("listOfStructs", null); | ||
| AtlasEntitiesWithExtInfo complexEntityInfo = new AtlasEntitiesWithExtInfo(complexEntity); | ||
| EntityMutationResponse responseUpdated = entityStore.createOrUpdate(new AtlasEntityStream(complexEntityInfo), false); | ||
| AtlasEntityHeader updatedComplexEntity = responseUpdated.getFirstUpdatedEntityByTypeName(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); |
Contributor
There was a problem hiding this comment.
updatedComplexEntity is a AtlasEntityHeader - which will not have all attributes of an entity, hence the asset at line #235 passes. Please get an entire entity and use that in assert:
AtlasEntityHeader updatedEntityHeader = responseUpdated.getFirstUpdatedEntityByTypeName(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR);
AtlasEntity updatedComplexEntity = getEntityFromStore(updatedEntityHeader);
Object updatedAttrValue = updatedComplexEntity.getAttribute("listOfStructs");
assertNull(updatedAttrValue, "listOfStructs");
Collaborator
|
This issue is fixed in ATLAS-2933, commit id https://gitbox.apache.org/repos/asf?p=atlas.git;a=commit;h=14037eed5c380006b0d622842677e362057a433a Closing the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Empty array attributes are returned as null instead of an empty list