You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2015/05/11 16:19:10 UTC
svn commit: r1678758 -
/jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java
Author: alexparvulescu
Date: Mon May 11 14:19:09 2015
New Revision: 1678758
URL: http://svn.apache.org/r1678758
Log:
OAK-2861 TARMK Cold Standby better binary decoding
Modified:
jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java
Modified: jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java?rev=1678758&r1=1678757&r2=1678758&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java (original)
+++ jackrabbit/oak/trunk/oak-tarmk-standby/src/main/java/org/apache/jackrabbit/oak/plugins/segment/standby/codec/ReplyDecoder.java Mon May 11 14:19:09 2015
@@ -113,8 +113,18 @@ public class ReplyDecoder extends Replay
long msb = in.readLong();
long lsb = in.readLong();
long hash = in.readLong();
- byte[] segment = new byte[len - 25];
- in.readBytes(segment);
+
+ // #readBytes throws a 'REPLAY' exception if there are not enough bytes
+ // available for reading
+ ByteBuf data = in.readBytes(len - 25);
+ byte[] segment;
+ if (data.hasArray()) {
+ segment = data.array();
+ } else {
+ segment = new byte[len - 25];
+ in.readBytes(segment);
+ }
+
Hasher hasher = Hashing.murmur3_32().newHasher();
long check = hasher.putBytes(segment).hash().padToLong();
if (hash == check) {
@@ -135,8 +145,17 @@ public class ReplyDecoder extends Replay
String id = new String(bid, Charset.forName("UTF-8"));
long hash = in.readLong();
- byte[] blob = new byte[length];
- in.readBytes(blob);
+ // #readBytes throws a 'REPLAY' exception if there are not enough bytes
+ // available for reading
+ ByteBuf data = in.readBytes(length);
+ byte[] blob;
+ if (data.hasArray()) {
+ blob = data.array();
+ } else {
+ blob = new byte[length];
+ data.readBytes(blob);
+ }
+
Hasher hasher = Hashing.murmur3_32().newHasher();
long check = hasher.putBytes(blob).hash().padToLong();
if (hash == check) {