in DynamoDbEncryption/runtimes/java/src/main/sdkv1/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptor.java [695:738]
protected static Map<String, String> unmarshallDescription(
AttributeValue attributeValue
) {
attributeValue.getB().mark();
try (
DataInputStream in = new DataInputStream(
new ByteBufferInputStream(attributeValue.getB())
)
) {
Map<String, String> result = new HashMap<String, String>();
int version = in.readInt();
if (version != CURRENT_VERSION) {
throw new IllegalArgumentException("Unsupported description version");
}
String key, value;
int keyLength, valueLength;
try {
while (in.available() > 0) {
keyLength = in.readInt();
byte[] bytes = new byte[keyLength];
if (in.read(bytes) != keyLength) {
throw new IllegalArgumentException("Malformed description");
}
key = new String(bytes, UTF8);
valueLength = in.readInt();
bytes = new byte[valueLength];
if (in.read(bytes) != valueLength) {
throw new IllegalArgumentException("Malformed description");
}
value = new String(bytes, UTF8);
result.put(key, value);
}
} catch (EOFException eof) {
throw new IllegalArgumentException("Malformed description", eof);
}
return result;
} catch (IOException ex) {
// Due to the objects in use, an IOException is not possible.
throw new RuntimeException("Unexpected exception", ex);
} finally {
attributeValue.getB().reset();
}
}