Skip to content

Commit

Permalink
bug fixed for parseArray use blank input
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 10, 2016
1 parent b3a49ed commit 10fa65b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/alibaba/fastjson/JSON.java
Expand Up @@ -340,9 +340,12 @@ public static <T> List<T> parseArray(String text, Class<T> clazz) {

DefaultJSONParser parser = new DefaultJSONParser(text, ParserConfig.getGlobalInstance());
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
int token = lexer.token();
if (token == JSONToken.NULL) {
lexer.nextToken();
list = null;
} else if (token == JSONToken.EOF && lexer.isBlankInput()) {
list = null;
} else {
list = new ArrayList<T>();
parser.parseArray(clazz, list);
Expand Down
@@ -0,0 +1,17 @@
package com.alibaba.json.bvt.parser.bug;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;

public class EmptyParseArrayTest extends TestCase {
public void test_0() throws Exception {
Assert.assertNull(JSON.parseArray("", VO.class));
}

public static class VO {

}
}

0 comments on commit 10fa65b

Please sign in to comment.