From abf5437826ea4b86bc327478dc707119ab851f49 Mon Sep 17 00:00:00 2001 From: Micah Zoltu Date: Thu, 18 Feb 2016 22:32:33 +0000 Subject: [PATCH] Fixes a bug where a blob couldn't be matched against twice. The `ByteBuffer` `bb` here may be used multiple times. The first time it is used, `bb` will correctly write out to the array `b`. However, the second time it is used the buffer will already be fully read so `b` will be a zero length array with nothing in it. By flipping the ByteBuffer after use, we are able to use it over and over again. --- src/main/java/org/scassandra/cql/CqlBlob.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scassandra/cql/CqlBlob.java b/src/main/java/org/scassandra/cql/CqlBlob.java index 5702605..0b8fdaa 100644 --- a/src/main/java/org/scassandra/cql/CqlBlob.java +++ b/src/main/java/org/scassandra/cql/CqlBlob.java @@ -19,6 +19,7 @@ public boolean equals(Object expected, Object actual) { ByteBuffer bb = (ByteBuffer) expected; byte[] b = new byte[bb.remaining()]; bb.get(b); + bb.flip(); String encodedExpected = Hex.encodeHexString(b); String actualWithout0x = actual.toString().replaceFirst("0x", ""); return encodedExpected.equals(actualWithout0x);