javajsongsonruntime-errorfuturetask

Gson deserialization throws FutureTask error


CASE SOLVED

UPDATE: The thing was that GSON have problems trying to deserialize into an Long object while it is into a running Thread, all I had to do was to deserialize manually my String by adding the part of the String with the long number into another String object and only after that cast it as Long into my Long object.Hope this will help somebody else.

So I use Kafka and in some data that kafka gives me from Topic I need to deserialize it (the same data I serializated and put it to the topic).But this throws and FutureTask error. how I serialize :

mKafkaProducer.sendMessage(
                    LoadBalancingManager.getGson().toJson(mCentralHbKey, CentralMetaMessageKey.class),
                    LoadBalancingManager.getGson().toJson(fcsTakenWithTime,
                            new TypeToken<HashMap<ArrayList<Integer>, Long>>() {
                            }.getType()));

And here is how I deserialize after I check if is the same object :

Map<ArrayList<Integer>, Long> incerc = LoadBalancingManager.getGson().fromJson(
                                        record.value(), new TypeToken<HashMap<ArrayList<Integer>, Long>>(){}.getType());

To serialize it works.

I've done other deserializations in same thread and they works , can't think to what's wrong...

I am using logger and my stack trace doesn't show any error but I follow the steps and here it goes after returning my deserialization : FutureTask error


Solution

  • The thing was that GSON have problems trying to deserialize into an Long object while it is into a running Thread, all I had to do was to deserialize manually my String by adding the part of the String with the long number into another String object and only after that cast it as Long into my Long object.Hope this will help somebody else.