Fix #71: Nova: Permit host-aggregate metadata to be deleted#106
Fix #71: Nova: Permit host-aggregate metadata to be deleted#106bboyHan wants to merge 1 commit intoopenstack4j:masterfrom
Conversation
|
@bboyHan, thanks for the patch. Note that Jackson seems to have corresponding functionality already: http://fasterxml.github.io/jackson-annotations/javadoc/2.6/com/fasterxml/jackson/annotation/JsonInclude.html |
|
The problem does not seem to be that JSON serialization is not supported. But because the api used to set parameters in class of org.openstack4j.core.transport.ObjectMapperSingleton: mapper.setSerializationInclusion(Include.NON_NULL); So it can not support this problem. #106 |
|
Good point, I have not realized the code is actually forcing the use of It will make the model objects use the standard Jackson mechanism and gain more flexibility as it would support all the other inclusion strategies. Let me have a look at this. |
| metadata.put("key1", "value1"); | ||
| metadata.put("key2", null); | ||
| HostAggregate hostAggregate = osv3().compute().hostAggregates().setMetadata("aggregateId", metadata); | ||
| assertNotNull(hostAggregate); |
There was a problem hiding this comment.
The test is passing even without the fix.
| return type.getAnnotation(JsonRootName.class) == null ? INSTANCE.mapper : INSTANCE.rootMapper; | ||
| return type.getAnnotation(JsonRootName.class) == null ? | ||
| type.getAnnotation(SerializationAllowNull.class) == null ? INSTANCE.mapper : INSTANCE.mapper.setSerializationInclusion(Include.ALWAYS) : | ||
| type.getAnnotation(SerializationAllowNull.class) == null ? INSTANCE.rootMapper : INSTANCE.rootMapper.setSerializationInclusion(Include.ALWAYS); |
There was a problem hiding this comment.
Careful here, it changes the state of the shared mappers so it will propagate to unrelated serializations.
Fix openstack4j#71: Nova: Permit host-aggregate metadata to be deleted
|
Replaced by #110 |
#71