thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn Hachmann <bjoern.hachm...@metrigo.de>
Subject NPE during serialization
Date Tue, 22 Sep 2015 14:01:09 GMT
Repeatedly in the past we ran into the following problem with using Thrift
from Java:

Consider the following simple model:

enum Colour {
  red,
  blue
}

struct Product {
  string sku;
  map<Colour, i32> inventory;
}

In our scenario Service A uses this version of the model. Service B uses a
newer version in which a new enum value "green" has been introduced.

Under the following circumstances:
1) B serializes a product in which an inventory entry is contained for
green.
2) A deserializes this product. As it does not know of green yet, the
problematic map key is deserialized as null.
3) A serializes the product again and runs into a NullPointerException.

My questions are:
1) Could this be a bug or should we somehow implement counter measures
against such cases? I think it feels a little weird to run
into this issue when using Thrift as there are several other similar
scenarious in which such a version mismatch is handled more gracefully.
2) Are there any best practices to deal with this case?

Thank you for your opinion!

Kind regards
Bjoern Hachmann

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message