Skip to content

Loading…

Fixing a minor off by one error #2

Merged
merged 1 commit into from

2 participants

@matt-martin

This probably has not affected anybody, but noticed it as I was looking through the code.

Matt Martin Off by one error could cause 'index out of range error' if the user p…
…rovides more qualifiers than values.
66d9b7c
@larsgeorge
Owner

You are right, thanks for the fix!

@larsgeorge larsgeorge merged commit 6cbb40c into larsgeorge:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 25, 2012
  1. Off by one error could cause 'index out of range error' if the user p…

    Matt Martin committed
    …rovides more qualifiers than values.
View
2 ch03/src/main/java/util/HBaseHelper.java
@@ -151,7 +151,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
View
2 ch04/src/main/java/util/HBaseHelper.java
@@ -142,7 +142,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
View
2 ch05/src/main/java/util/HBaseHelper.java
@@ -142,7 +142,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
View
2 ch06/src/main/java/util/HBaseHelper.java
@@ -142,7 +142,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
View
2 ch07/src/main/java/util/HBaseHelper.java
@@ -142,7 +142,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
View
2 ch09/src/main/java/util/HBaseHelper.java
@@ -151,7 +151,7 @@ public void put(String table, String[] rows, String[] fams, String[] quals,
for (String fam : fams) {
int v = 0;
for (String qual : quals) {
- String val = vals[v < vals.length ? v : vals.length];
+ String val = vals[v < vals.length ? v : vals.length - 1];
long t = ts[v < ts.length ? v : ts.length - 1];
put.add(Bytes.toBytes(fam), Bytes.toBytes(qual), t,
Bytes.toBytes(val));
Something went wrong with that request. Please try again.