Skip to content

Commit a21b3f4

Browse files
Sumanth Pasupuletisumanth-pasupuleti
authored andcommitted
Adding column name validation in tandem with checksum validation
1 parent 0227f85 commit a21b3f4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

ndbench-cass-plugins/src/main/java/com/netflix/ndbench/plugin/cass/CassAstyanaxPlugin.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import com.google.common.collect.ImmutableMap;
23+
import com.netflix.astyanax.model.Column;
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
2526

@@ -131,7 +132,16 @@ public String readSingle(String key) throws Exception {
131132
{
132133
for (int i = 0; i < result.size(); i++)
133134
{
134-
String value = result.getColumnByIndex(i).getStringValue();
135+
Column<Integer> column = result.getColumnByIndex(i);
136+
137+
// validate column name
138+
if (column.getName() != i)
139+
{
140+
throw new Exception(String.format("Column name %d does not match with the expected column name %d", column.getName(), i));
141+
}
142+
143+
// validate column value checksum
144+
String value = column.getStringValue();
135145
if (!CheckSumUtil.isChecksumValid(value))
136146
{
137147
throw new Exception(String.format("Value %s is corrupt. Key %s.", value, key));

0 commit comments

Comments
 (0)