diff --git a/client/src/com/aerospike/client/cdt/CTX.java b/client/src/com/aerospike/client/cdt/CTX.java index 40afa98f9..4ffbdbfec 100644 --- a/client/src/com/aerospike/client/cdt/CTX.java +++ b/client/src/com/aerospike/client/cdt/CTX.java @@ -138,22 +138,20 @@ public static byte[] toBytes(CTX[] ctx) { public static CTX[] fromBytes(byte[] bytes) { List list = (List)Unpacker.unpackObjectList(bytes, 0, bytes.length); int max = list.size(); - CTX[] ctx = new CTX[max / 2]; - int i = 0; - int count = 0; - while (i < max) { - int id = (int)(long)(Long)list.get(i); + if ((max & 1) != 0) { + throw new AerospikeException.Parse("List count must be even"); + } - if (++i >= max) { - throw new AerospikeException.Parse("List count must be even"); - } + CTX[] ctx = new CTX[max / 2]; + int count = 0; - Object obj = list.get(i); + for (int i = 0; i < max; i += 2) { + int id = ((Number) list.get(i)).intValue(); + Object obj = list.get(i + 1); Value val = Value.get(obj); ctx[count++] = new CTX(id, val); - i++; } return ctx; }