Permalink
Browse files

Fix max sequence length constant to reflect the maximum value storabl…

…e in 30 bits.
  • Loading branch information...
1 parent 310912e commit 34d0c0d8a2185c0bca43e02e5c6bd9bad275bf5a @jkreps jkreps committed Nov 30, 2009
Showing with 2 additions and 3 deletions.
  1. +2 −3 src/java/voldemort/serialization/json/JsonTypeSerializer.java
@@ -45,8 +45,7 @@
*/
public class JsonTypeSerializer implements Serializer<Object> {
- // TODO: not correct, should be less than this
- private static final int MAX_SEQ_LENGTH = Integer.MAX_VALUE;
+ private static final int MAX_SEQ_LENGTH = 0x3FFFFFFF;
private final boolean hasVersion;
private final SortedMap<Integer, JsonTypeDefinition> typeDefVersions;
@@ -551,7 +550,7 @@ private void writeList(DataOutputStream output, List<Object> objects, List<Objec
private void writeLength(DataOutputStream stream, int size) throws IOException {
if(size < Short.MAX_VALUE) {
stream.writeShort(size);
- } else if(size < MAX_SEQ_LENGTH) {
+ } else if(size <= MAX_SEQ_LENGTH) {
stream.writeInt(size | 0xC0000000);
} else {
throw new SerializationException("Invalid length: maximum is " + MAX_SEQ_LENGTH);

0 comments on commit 34d0c0d

Please sign in to comment.