The following issues were found
src/test/java/com/alibaba/json/bvt/ArmoryTest.java
4 issues
Line: 14
public class ArmoryTest extends TestCase {
public void test_item() throws Exception {
Item item = new Item();
String text = JSON.toJSONString(item, SerializerFeature.SortField, SerializerFeature.UseSingleQuotes);
Assert.assertEquals("{'id':0,'name':'xx'}", text);
}
Reported by PMD.
Line: 20
Assert.assertEquals("{'id':0,'name':'xx'}", text);
}
public void test_0() throws Exception {
List<Object> message = new ArrayList<Object>();
MessageBody body = new MessageBody();
Item item = new Item();
body.getItems().add(item);
Reported by PMD.
Line: 24
List<Object> message = new ArrayList<Object>();
MessageBody body = new MessageBody();
Item item = new Item();
body.getItems().add(item);
message.add(new MessageHead());
message.add(body);
String text = JSON.toJSONString(message, SerializerFeature.SortField, SerializerFeature.UseSingleQuotes);
Reported by PMD.
Line: 33
Assert.assertEquals("[{},{'items':[{'id':0,'name':'xx'}]}]", text);
}
public static class Item {
private int id;
private String name = "xx";
public int getId() {
return id;
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/LongCodec.java
4 issues
Line: 85
return null;
}
}
} catch (Exception ex) {
throw new JSONException("parseLong error, field : " + fieldName, ex);
}
return clazz == AtomicLong.class //
? (T) new AtomicLong(longObject.longValue()) //
Reported by PMD.
Line: 90
}
return clazz == AtomicLong.class //
? (T) new AtomicLong(longObject.longValue()) //
: (T) longObject;
}
public int getFastMatchToken() {
return JSONToken.LITERAL_INT;
Reported by PMD.
Line: 66
if (token == JSONToken.LITERAL_INT) {
long longValue = lexer.longValue();
lexer.nextToken(JSONToken.COMMA);
longObject = Long.valueOf(longValue);
} else if (token == JSONToken.LITERAL_FLOAT) {
BigDecimal number = lexer.decimalValue();
longObject = TypeUtils.longValue(number);
lexer.nextToken(JSONToken.COMMA);
} else {
Reported by PMD.
Line: 69
longObject = Long.valueOf(longValue);
} else if (token == JSONToken.LITERAL_FLOAT) {
BigDecimal number = lexer.decimalValue();
longObject = TypeUtils.longValue(number);
lexer.nextToken(JSONToken.COMMA);
} else {
if (token == JSONToken.LBRACE) {
JSONObject jsonObject = new JSONObject(true);
parser.parseObject(jsonObject);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue887.java
4 issues
Line: 15
Foo excepted = new Foo();
excepted.setName("mock");
String json;
System.out.println(json = JSON.toJSONString(excepted, true));
Foo actually = JSON.parseObject(json, Foo.class);
assertEquals(excepted.getName(), actually.getName());
}
public static class Foo {
Reported by PMD.
Line: 11
* Created by wenshao on 2016/11/10.
*/
public class Issue887 extends TestCase {
public void test_for_issue() throws Exception {
Foo excepted = new Foo();
excepted.setName("mock");
String json;
System.out.println(json = JSON.toJSONString(excepted, true));
Foo actually = JSON.parseObject(json, Foo.class);
Reported by PMD.
Line: 17
String json;
System.out.println(json = JSON.toJSONString(excepted, true));
Foo actually = JSON.parseObject(json, Foo.class);
assertEquals(excepted.getName(), actually.getName());
}
public static class Foo {
@JSONField(name = "foo.name")
private String name;
Reported by PMD.
Line: 17
String json;
System.out.println(json = JSON.toJSONString(excepted, true));
Foo actually = JSON.parseObject(json, Foo.class);
assertEquals(excepted.getName(), actually.getName());
}
public static class Foo {
@JSONField(name = "foo.name")
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/atomic/AtomicLongReadOnlyTest.java
4 issues
Line: 13
public class AtomicLongReadOnlyTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0(123);
String text = JSON.toJSONString(v);
Assert.assertEquals("{\"value\":123}", text);
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
}
public static class V0 {
private final AtomicLong value;
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
}
public static class V0 {
private final AtomicLong value;
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().intValue(), v.getValue().intValue());
}
public static class V0 {
private final AtomicLong value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_lenolix_5.java
4 issues
Line: 21
final String newJsonString = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteClassName);
System.out.println(newJsonString);
final Object newObject = JSON.parse(newJsonString);
System.out.println(newObject);
}
Reported by PMD.
Line: 25
final Object newObject = JSON.parse(newJsonString);
System.out.println(newObject);
}
}
Reported by PMD.
Line: 13
public class Bug_for_lenolix_5 extends TestCase {
public void test_for_objectKey() throws Exception {
final Map<Object, Object> obj = new HashMap<Object, Object>();
final Object obja = new Object();
final Object objb = new Object();
obj.put(obja, objb);
Reported by PMD.
Line: 13
public class Bug_for_lenolix_5 extends TestCase {
public void test_for_objectKey() throws Exception {
final Map<Object, Object> obj = new HashMap<Object, Object>();
final Object obja = new Object();
final Object objb = new Object();
obj.put(obja, objb);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_676.java
4 issues
Line: 12
public class Bug_for_issue_676 extends TestCase {
public void test_for_issue() throws Exception {
JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);
}
public static class MenuExpend {
public ModelType modelType;
Reported by PMD.
Line: 12
public class Bug_for_issue_676 extends TestCase {
public void test_for_issue() throws Exception {
JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);
}
public static class MenuExpend {
public ModelType modelType;
Reported by PMD.
Line: 5
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.ASMUtils;
Reported by PMD.
Line: 8
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.ASMUtils;
public class Bug_for_issue_676 extends TestCase {
public void test_for_issue() throws Exception {
JSON.parseObject("{\"modelType\":\"\"}", MenuExpend.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest2.java
4 issues
Line: 14
public class JSONObjectTest2 extends TestCase {
public void test_0() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
JSONObject obj = new JSONObject(map);
Assert.assertEquals(obj.size(), map.size());
Reported by PMD.
Line: 26
map.put("b", new int[] { 1 });
JSONArray array = obj.getJSONArray("b");
Assert.assertEquals(array.size(), 1);
map.put("c", new JSONArray());
JSONArray array2 = obj.getJSONArray("b");
Assert.assertEquals(array2.size(), 1);
Reported by PMD.
Line: 30
map.put("c", new JSONArray());
JSONArray array2 = obj.getJSONArray("b");
Assert.assertEquals(array2.size(), 1);
Assert.assertEquals(obj.getByteValue("d"), 0);
Assert.assertEquals(obj.getShortValue("d"), 0);
Assert.assertTrue(obj.getFloatValue("d") == 0F);
Assert.assertTrue(obj.getDoubleValue("d") == 0D);
Reported by PMD.
Line: 41
Assert.assertEquals(obj.getTimestamp("d"), null);
JSONObject obj2 = (JSONObject) obj.clone();
Assert.assertEquals(obj.size(), obj2.size());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_10.java
4 issues
Line: 9
public class Bug_10 extends TestCase {
public void test_0() throws Exception {
String text = "{'jdbcUrl':\"jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8\"}";
JSON.parse(text);
}
Reported by PMD.
Line: 9
public class Bug_10 extends TestCase {
public void test_0() throws Exception {
String text = "{'jdbcUrl':\"jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8\"}";
JSON.parse(text);
}
Reported by PMD.
Line: 15
JSON.parse(text);
}
public void test_1() throws Exception {
String text = "{'jdbcUrl':'jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8'}";
JSON.parse(text);
}
Reported by PMD.
Line: 15
JSON.parse(text);
}
public void test_1() throws Exception {
String text = "{'jdbcUrl':'jdbc:wrap-jdbc:filters=default:name=com.alibaba.dragoon.monitor:jdbc:mysql:\\/\\/10.20.129.167\\/dragoon_v25monitordb?useUnicode=true&characterEncoding=UTF-8'}";
JSON.parse(text);
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/geo/Geometry.java
4 issues
Line: 18
, Feature.class
, FeatureCollection.class}
, typeKey = "type")
public abstract class Geometry {
private final String type;
private double[] bbox;
protected Geometry(String type) {
this.type = type;
Reported by PMD.
Line: 31
}
public double[] getBbox() {
return bbox;
}
public void setBbox(double[] bbox) {
this.bbox = bbox;
}
Reported by PMD.
Line: 34
return bbox;
}
public void setBbox(double[] bbox) {
this.bbox = bbox;
}
}
Reported by PMD.
Line: 34
return bbox;
}
public void setBbox(double[] bbox) {
this.bbox = bbox;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CharsetFieldTest.java
4 issues
Line: 14
public class CharsetFieldTest extends TestCase {
public void test_codec() throws Exception {
User user = new User();
user.setValue(Charset.forName("UTF-8"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 27
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 37
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public static class User {
private Charset value;
Reported by PMD.