Description
I'm using FlexibleAggregationStrategy to aggregate objects into collection. I found following issue where Aggregator ends up overwriting old collection with the new one.
JdbcCamelCodec is not marshaling all of the exchange properties.
E.g. it does not marshal exchange's 'CamelFlexAggrStrCollectionGuard' property.
So next time Aggregator tries to fetch BLOB from database, oldExchange does not have above property.
So following code creates new collection for each new object, and hence overwrites the old collection.
private Collection<E> FlexibleAggregationStrategy::safeInsertIntoCollection(Exchange oldExchange, Collection<E> oldValue, E toInsert) {
Collection<E> collection = null;
try {
if (oldValue == null || oldExchange.getProperty(COLLECTION_AGGR_GUARD_PROPERTY, Boolean.class) == null) {
try {
collection = collectionType.newInstance(); //**EVERYTIME NEW COLLECTION as previous aggregation did not serialize COLLECTION_AGGR_GUARD_PROPERTY to database.