Jackson serialization stops working after upgrade to 3.7.x from 3.6.x

45 views
Skip to first unread message

Steve Hu

unread,
Sep 29, 2017, 5:14:58 PM9/29/17
to Hazelcast
The following code calls values on IMap with a pagingPredicate. In 3.7.x, the values collection contains ResultSet object which cannot be serialised by Jackson writeValueAsString()


IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");

Deque<String> serviceIdDeque = exchange.getQueryParameters().get("serviceId");
String serviceId = serviceIdDeque == null? "%" : serviceIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());

LikePredicate likePredicate = new LikePredicate("serviceId", serviceId);

PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ServiceComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Service> values = services.values(pagingPredicate);

exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));


The error is 

com.fasterxml.jackson.databind.JsonMappingException: Class com.networknt.oauth.cache.model.Service not subtype of [simple type, class java.util.Map$Entry<java.lang.Object,java.lang.Object>] (through reference chain: com.hazelcast.replicatedmap.impl.record.ResultSet[0])


It looks like the object is just a reference which cannot be handled by Jackson. Is there any way we can convert
the result to POJO so that it can be serialized?

Thanks,

Steve





Ahmet Mircik

unread,
Oct 2, 2017, 9:05:03 AM10/2/17
to Hazelcast

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+unsubscribe@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/0a3f8ed6-2fed-4fc2-8ad1-d7aa1d99a175%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages