I'm scanning the hbase for md5 string and I have to perform some actions, if there are strings found. The problem is, that if I check it first time, it returns true (and at log is the value), but then, when I use same expression in if or for statement I got a false result.
Scan scanCookiesData = new Scan();
scanCookiesData.addColumn(Bytes.toBytes("md5data"), Bytes.toBytes("md5data"));
ResultScanner scannerCookiesData = dbHelper.getTable("userInfo").getScanner(scanCookiesData);
if (scannerCookiesData.next() != null) {
response.getWriter().println("if (scannerCookiesData.next() != null)");
for (Result r = scannerCookiesData.next(); r != null; r = scannerCookiesData.next()) {
response.getWriter().println("INSIDE FOR!!!");
if (md5data.equals(Bytes.toString(r.value()))) {
// Here we will assign ID to the user.
response.getWriter().println(assignID(Bytes.toString(r.value())));
response.setStatus(200);
} else {
response.getWriter().println("ELSE");
}
}
} else {
response.getWriter().println(createNewUser(json));
response.setStatus(200);
}
In this code, at first if it gets "true", but in for is not invoked, as it will show "false".. but scanner is not a null (in db is that md5 string), so it should get "true"..
Aucun commentaire:
Enregistrer un commentaire