...
Jackson is tailored towards parsing larger files. According to cited benchmarks it is slower than GSON with large files and much slower with small files.
...
GSON is faster than Jackson parsermapper. However, as mentioned in the use case above, GSON is not capable of parsing well when it does not know the data type which it is parsingmapping. It is possible to cast the incoming data to the correct datatype but it is not useful in the case where we do not know the incoming datatype. As such, in the use case mentioned above it is more practical to use the Jackson parser.
Legacy Code
The cited article also shows benchmarks from 2017 in which Jackson parser was out performing GSON in the large file category. We can surmise that there is a constant battle between these objectMappers and Jackson may begin out performing GSON again in the future.
Resolution
It would make the most sense to use GSON as much as possible as it is the faster than Jackson. However the practicality of Jacksons parsing cannot be overlooked. Therefore it would make sense to use the Jackson parser in this scenario. We also don't want to have or create a Jackson parser mapper and GSON parser mapper object in the same file however as the memory cost is quite high.
- GSON parser should solely be used in a class where possible.
- In the case where the Jackson parser mapper is necessary, the Jackson parser mapper should be used in the whole class so that there is only one parser object created for a class.
CPS-NCMP
- CpsDataPersistenceServiceImpl.java is is using two parser objectsmapper objects, GSON and Jackson, should be just Jackson
- NetworkCmProxyInventoryController.java is is using the Jackson parser mapper where the GSON parser could be used instead
- NetworkCmProxyDataServiceImpl.java is is using the Jackson parser mapper where the GSON parser could be used insteadhttps://github.com/onap/cps-cps-temporal/blob/2a41a4f022af65ab878f6e6f7646e78d4ef27a06/src/main/java/org/onap/cps/temporal/controller/event/model/CpsDataUpdatedEventMapper.java
Temporal
- CpsDataUpdatedEventMapper.java is using Jackson mapper where GSON could be used instead