From a21b3f480abf10855dc3675d13d09c52a4e06cb6 Mon Sep 17 00:00:00 2001 From: Sumanth Pasupuleti Date: Wed, 8 Jan 2020 20:20:57 -0800 Subject: [PATCH] Adding column name validation in tandem with checksum validation --- .../ndbench/plugin/cass/CassAstyanaxPlugin.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ndbench-cass-plugins/src/main/java/com/netflix/ndbench/plugin/cass/CassAstyanaxPlugin.java b/ndbench-cass-plugins/src/main/java/com/netflix/ndbench/plugin/cass/CassAstyanaxPlugin.java index 68aff4a0..04b120b2 100644 --- a/ndbench-cass-plugins/src/main/java/com/netflix/ndbench/plugin/cass/CassAstyanaxPlugin.java +++ b/ndbench-cass-plugins/src/main/java/com/netflix/ndbench/plugin/cass/CassAstyanaxPlugin.java @@ -20,6 +20,7 @@ import java.util.Map; import com.google.common.collect.ImmutableMap; +import com.netflix.astyanax.model.Column; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -131,7 +132,16 @@ public String readSingle(String key) throws Exception { { for (int i = 0; i < result.size(); i++) { - String value = result.getColumnByIndex(i).getStringValue(); + Column column = result.getColumnByIndex(i); + + // validate column name + if (column.getName() != i) + { + throw new Exception(String.format("Column name %d does not match with the expected column name %d", column.getName(), i)); + } + + // validate column value checksum + String value = column.getStringValue(); if (!CheckSumUtil.isChecksumValid(value)) { throw new Exception(String.format("Value %s is corrupt. Key %s.", value, key));