Skip to content

Commit

Permalink
[FLINK-5576] [queryable state] Improve failure message deserializeList
Browse files Browse the repository at this point in the history
As in FLINK-5559, wrap the original IOException into a new one with an
appropriate error message to better diagnose it.
  • Loading branch information
Nico Kruber authored and uce committed Jan 22, 2017
1 parent c1c6ef1 commit 3fe2cf5
Showing 1 changed file with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,24 +453,32 @@ public static <T> T deserializeValue(byte[] serializedValue, TypeSerializer<T> s
*/
public static <T> List<T> deserializeList(byte[] serializedValue, TypeSerializer<T> serializer) throws IOException {
if (serializedValue != null) {
DataInputDeserializer in = new DataInputDeserializer(serializedValue, 0, serializedValue.length);

List<T> result = new ArrayList<>();
while (in.available() > 0) {
result.add(serializer.deserialize(in));

// The expected binary format has a single byte separator. We
// want a consistent binary format in order to not need any
// special casing during deserialization. A "cleaner" format
// would skip this extra byte, but would require a memory copy
// for RocksDB, which stores the data serialized in this way
// for lists.
if (in.available() > 0) {
in.readByte();
final DataInputDeserializer in = new DataInputDeserializer(
serializedValue, 0, serializedValue.length);

try {
final List<T> result = new ArrayList<>();
while (in.available() > 0) {
result.add(serializer.deserialize(in));

// The expected binary format has a single byte separator. We
// want a consistent binary format in order to not need any
// special casing during deserialization. A "cleaner" format
// would skip this extra byte, but would require a memory copy
// for RocksDB, which stores the data serialized in this way
// for lists.
if (in.available() > 0) {
in.readByte();
}
}
}

return result;
return result;
} catch (IOException e) {
throw new IOException(
"Unable to deserialize value. " +
"This indicates a mismatch in the value serializers " +
"used by the KvState instance and this access.", e);
}
} else {
return null;
}
Expand Down

0 comments on commit 3fe2cf5

Please sign in to comment.