Skip to content

Commit

Permalink
bug fixed for JSONScanner. issue #1001
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 21, 2017
1 parent 9ce20b3 commit 7dd9f89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Expand Up @@ -165,7 +165,7 @@ public final char next() {
if (sp > 0) {
int offset;
offset = bufLength - sp;
if (ch == '"') {
if (ch == '"' && offset > 0) {
offset--;
}
System.arraycopy(buf, offset, buf, 0, sp);
Expand Down Expand Up @@ -298,7 +298,7 @@ public final BigDecimal decimalValue() {
public void close() {
super.close();

if (buf.length <= 1024 * 32) {
if (buf.length <= 1024 * 64) {
BUF_LOCAL.set(buf);
}
this.buf = null;
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/com/alibaba/json/test/Issue1001.java
@@ -0,0 +1,23 @@
package com.alibaba.json.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONReader;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.StringReader;

/**
* Created by wenshao on 21/01/2017.
*/
public class Issue1001 extends TestCase {
public void test_for_issue() throws Exception {
File file = new File("/Users/wenshao/Downloads/issue_1001.json");

String json = FileUtils.readFileToString(file);

JSONReader reader = new JSONReader(new StringReader(json));
reader.readObject();
}
}

0 comments on commit 7dd9f89

Please sign in to comment.