修复JsonByteBuffer解析bug
This commit is contained in:
@@ -164,6 +164,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
if (ch == 'N' && nextChar() == 'U' && nextChar() == 'L' && nextChar() == 'L') {
|
||||
return SIGN_NULL;
|
||||
}
|
||||
int pos = this.position;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ch);
|
||||
char one;
|
||||
@@ -171,7 +172,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
while ((one = nextChar()) != 0) sb.append(one);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new ConvertException("a json array text must begin with '[' (position = " + position + ") but '" + ch + "' in (" + sb + ")");
|
||||
throw new ConvertException("a json array text must begin with '[' (position = " + pos + ") but '" + ch + "' in (" + sb + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,6 +184,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
if (ch == ':') {
|
||||
return;
|
||||
}
|
||||
int pos = this.position;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ch);
|
||||
char one;
|
||||
@@ -190,7 +192,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
while ((one = nextChar()) != 0) sb.append(one);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new ConvertException("expected a ':' but '" + ch + "'(position = " + position + ") in (" + sb + ")");
|
||||
throw new ConvertException("expected a ':' but '" + ch + "'(position = " + pos + ") in (" + sb + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -365,7 +365,7 @@ public class JsonReader extends Reader {
|
||||
if (nt == '}' || nt == ']') {
|
||||
return false;
|
||||
}
|
||||
backChar(ch);
|
||||
backChar(nt);
|
||||
return true;
|
||||
}
|
||||
if (ch == '}' || ch == ']') {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -31,17 +31,18 @@ public final class ByteArray implements ByteTuple {
|
||||
}
|
||||
|
||||
public ByteArray(int size) {
|
||||
content = new byte[Math.max(1, size)];
|
||||
this.content = new byte[Math.max(1, size)];
|
||||
}
|
||||
|
||||
public ByteArray(ByteTuple tuple) {
|
||||
content = tuple.content();
|
||||
count = tuple.length();
|
||||
this.content = tuple.content();
|
||||
this.count = tuple.length();
|
||||
}
|
||||
|
||||
public ByteArray(byte[] bs) {
|
||||
content = bs;
|
||||
count = 0;
|
||||
Objects.requireNonNull(bs);
|
||||
this.content = bs;
|
||||
this.count = bs.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user